Java Code Examples for com.thinkaurelius.titan.core.TitanException

The following are top voted examples for showing how to use com.thinkaurelius.titan.core.TitanException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: keti   File: GraphResourceRepositoryTest.java   Source Code and License 6 votes vote down vote up
static <E extends ZonableEntity> E saveWithRetry(final GraphGenericRepository<E> repository,
        final E zonableEntity, final int retryCount) throws TitanException {
    try {
        repository.save(zonableEntity);
    } catch (TitanException te) {
        if (te.getCause().getCause().getMessage().contains("Local lock") && retryCount > 0) {
            try {
                Thread.sleep(250);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            zonableEntity.setId(0L); // Repository does not reset the vertex Id, on commit failure. Clear.
            saveWithRetry(repository, zonableEntity, retryCount - 1);
        } else {
            throw te;
        }
    }
    return zonableEntity;
}
 
Example 2
Project: titan1withtp3.1   File: TestMockLog.java   Source Code and License 6 votes vote down vote up
@Override
public synchronized Future<Message> add(StaticBuffer content) {
    TestMessage msg = new TestMessage(content);
    FutureMessage<TestMessage> fmsg = new FutureMessage<TestMessage>(msg);

    if (failAdds) {
        System.out.println("Failed message add");
        throw new TitanException("Log unavailable");
    }

    if (readers.isEmpty()) {
        messageBacklog.add(fmsg);
    } else {
        process(fmsg);
    }
    return fmsg;
}
 
Example 3
Project: titan1withtp3.1   File: BerkeleyGraphTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testIDBlockAllocationTimeout()
{
    config.set("ids.authority.wait-time", Duration.of(0L, ChronoUnit.NANOS));
    config.set("ids.renew-timeout", Duration.of(1L, ChronoUnit.MILLIS));
    close();
    TitanCleanup.clear(graph);
    open(config);
    try {
        graph.addVertex();
        fail();
    } catch (TitanException e) {

    }

    assertTrue(graph.isOpen());

    close(); // must be able to close cleanly

    // Must be able to reopen
    open(config);

    assertEquals(0L, (long)graph.traversal().V().count().next());
}
 
Example 4
Project: titan1withtp3.1   File: ElasticSearchIndex.java   Source Code and License 6 votes vote down vote up
/**
 * If ES already contains this instance's target index, then do nothing.
 * Otherwise, create the index, then wait {@link #CREATE_SLEEP}.
 * <p>
 * The {@code client} field must point to a live, connected client.
 * The {@code indexName} field must be non-null and point to the name
 * of the index to check for existence or create.
 *
 * @param config the config for this ElasticSearchIndex
 * @throws java.lang.IllegalArgumentException if the index could not be created
 */
private void checkForOrCreateIndex(Configuration config) {
    Preconditions.checkState(null != client);

    //Create index if it does not already exist
    IndicesExistsResponse response = client.admin().indices().exists(new IndicesExistsRequest(indexName)).actionGet();
    if (!response.isExists()) {

        ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder();

        ElasticSearchSetup.applySettingsFromTitanConf(settings, config, ES_CREATE_EXTRAS_NS);

        CreateIndexResponse create = client.admin().indices().prepareCreate(indexName)
                .setSettings(settings.build()).execute().actionGet();
        try {
            final long sleep = config.get(CREATE_SLEEP);
            log.debug("Sleeping {} ms after {} index creation returned from actionGet()", sleep, indexName);
            Thread.sleep(sleep);
        } catch (InterruptedException e) {
            throw new TitanException("Interrupted while waiting for index to settle in", e);
        }
        if (!create.isAcknowledged()) throw new IllegalArgumentException("Could not create index: " + indexName);
    }
}
 
Example 5
Project: titan1withtp3.1   File: ElasticSearchIndexTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testErrorInBatch() throws Exception {
    initialize("vertex");
    Multimap<String, Object> doc1 = HashMultimap.create();
    doc1.put(TIME, "not a time");

    add("vertex", "failing-doc", doc1, true);
    add("vertex", "non-failing-doc", getRandomDocument(), true);

    try {
        tx.commit();
        fail("Commit should not have succeeded.");
    } catch (TitanException e) {
        // Looking for a NumberFormatException since we tried to stick a string of text into a time field.
        if (!Throwables.getRootCause(e).getMessage().contains("NumberFormatException")) {
            throw e;
        }
    } finally {
        tx = null;
    }
}
 
Example 6
Project: titan1withtp3.1   File: ExpirationKCVSCache.java   Source Code and License 6 votes vote down vote up
@Override
public EntryList getSlice(final KeySliceQuery query, final StoreTransaction txh) throws BackendException {
    incActionBy(1, CacheMetricsAction.RETRIEVAL,txh);
    if (isExpired(query)) {
        incActionBy(1, CacheMetricsAction.MISS,txh);
        return store.getSlice(query, unwrapTx(txh));
    }

    try {
        return cache.get(query,new Callable<EntryList>() {
            @Override
            public EntryList call() throws Exception {
                incActionBy(1, CacheMetricsAction.MISS,txh);
                return store.getSlice(query, unwrapTx(txh));
            }
        });
    } catch (Exception e) {
        if (e instanceof TitanException) throw (TitanException)e;
        else if (e.getCause() instanceof TitanException) throw (TitanException)e.getCause();
        else throw new TitanException(e);
    }
}
 
Example 7
Project: titan1withtp3.1   File: Backend.java   Source Code and License 6 votes vote down vote up
public static KCVSConfiguration getStandaloneGlobalConfiguration(final KeyColumnValueStoreManager manager,
                                                                 final Configuration config) {
    try {
        final StoreFeatures features = manager.getFeatures();
        return getGlobalConfiguration(new BackendOperation.TransactionalProvider() {
            @Override
            public StoreTransaction openTx() throws BackendException {
                return manager.beginTransaction(StandardBaseTransactionConfig.of(config.get(TIMESTAMP_PROVIDER),features.getKeyConsistentTxConfig()));
            }

            @Override
            public void close() throws BackendException {
                manager.close();
            }
        },manager.openDatabase(SYSTEM_PROPERTIES_STORE_NAME),config);
    } catch (BackendException e) {
        throw new TitanException("Could not open global configuration",e);
    }
}
 
Example 8
Project: titan1withtp3.1   File: StandardLogProcessorFramework.java   Source Code and License 6 votes vote down vote up
@Override
public synchronized void shutdown() throws TitanException {
    if (!isOpen) return;
    isOpen = false;
    try {
        try {
            for (Log log : processorLogs.values()) {
                log.close();
            }
            processorLogs.clear();
        } finally {
        }
    } catch (BackendException e) {
        throw new TitanException(e);
    }
}
 
Example 9
Project: titan1.0.1.kafka   File: TestMockLog.java   Source Code and License 6 votes vote down vote up
@Override
public synchronized Future<Message> add(StaticBuffer content) {
    TestMessage msg = new TestMessage(content);
    FutureMessage<TestMessage> fmsg = new FutureMessage<TestMessage>(msg);

    if (failAdds) {
        System.out.println("Failed message add");
        throw new TitanException("Log unavailable");
    }

    if (readers.isEmpty()) {
        messageBacklog.add(fmsg);
    } else {
        process(fmsg);
    }
    return fmsg;
}
 
Example 10
Project: titan1.0.1.kafka   File: BerkeleyGraphTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testIDBlockAllocationTimeout()
{
    config.set("ids.authority.wait-time", Duration.of(0L, ChronoUnit.NANOS));
    config.set("ids.renew-timeout", Duration.of(1L, ChronoUnit.MILLIS));
    close();
    TitanCleanup.clear(graph);
    open(config);
    try {
        graph.addVertex();
        fail();
    } catch (TitanException e) {

    }

    assertTrue(graph.isOpen());

    close(); // must be able to close cleanly

    // Must be able to reopen
    open(config);

    assertEquals(0L, (long)graph.traversal().V().count().next());
}
 
Example 11
Project: titan1.0.1.kafka   File: ElasticSearchIndex.java   Source Code and License 6 votes vote down vote up
/**
 * If ES already contains this instance's target index, then do nothing.
 * Otherwise, create the index, then wait {@link #CREATE_SLEEP}.
 * <p>
 * The {@code client} field must point to a live, connected client.
 * The {@code indexName} field must be non-null and point to the name
 * of the index to check for existence or create.
 *
 * @param config the config for this ElasticSearchIndex
 * @throws java.lang.IllegalArgumentException if the index could not be created
 */
private void checkForOrCreateIndex(Configuration config) {
    Preconditions.checkState(null != client);

    //Create index if it does not already exist
    IndicesExistsResponse response = client.admin().indices().exists(new IndicesExistsRequest(indexName)).actionGet();
    if (!response.isExists()) {

        ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder();

        ElasticSearchSetup.applySettingsFromTitanConf(settings, config, ES_CREATE_EXTRAS_NS);

        CreateIndexResponse create = client.admin().indices().prepareCreate(indexName)
                .setSettings(settings.build()).execute().actionGet();
        try {
            final long sleep = config.get(CREATE_SLEEP);
            log.debug("Sleeping {} ms after {} index creation returned from actionGet()", sleep, indexName);
            Thread.sleep(sleep);
        } catch (InterruptedException e) {
            throw new TitanException("Interrupted while waiting for index to settle in", e);
        }
        if (!create.isAcknowledged()) throw new IllegalArgumentException("Could not create index: " + indexName);
    }
}
 
Example 12
Project: titan1.0.1.kafka   File: ElasticSearchIndexTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testErrorInBatch() throws Exception {
    initialize("vertex");
    Multimap<String, Object> doc1 = HashMultimap.create();
    doc1.put(TIME, "not a time");

    add("vertex", "failing-doc", doc1, true);
    add("vertex", "non-failing-doc", getRandomDocument(), true);

    try {
        tx.commit();
        fail("Commit should not have succeeded.");
    } catch (TitanException e) {
        // Looking for a NumberFormatException since we tried to stick a string of text into a time field.
        if (!Throwables.getRootCause(e).getMessage().contains("NumberFormatException")) {
            throw e;
        }
    } finally {
        tx = null;
    }
}
 
Example 13
Project: titan1.0.1.kafka   File: ExpirationKCVSCache.java   Source Code and License 6 votes vote down vote up
@Override
public EntryList getSlice(final KeySliceQuery query, final StoreTransaction txh) throws BackendException {
    incActionBy(1, CacheMetricsAction.RETRIEVAL,txh);
    if (isExpired(query)) {
        incActionBy(1, CacheMetricsAction.MISS,txh);
        return store.getSlice(query, unwrapTx(txh));
    }

    try {
        return cache.get(query,new Callable<EntryList>() {
            @Override
            public EntryList call() throws Exception {
                incActionBy(1, CacheMetricsAction.MISS,txh);
                return store.getSlice(query, unwrapTx(txh));
            }
        });
    } catch (Exception e) {
        if (e instanceof TitanException) throw (TitanException)e;
        else if (e.getCause() instanceof TitanException) throw (TitanException)e.getCause();
        else throw new TitanException(e);
    }
}
 
Example 14
Project: titan1.0.1.kafka   File: Backend.java   Source Code and License 6 votes vote down vote up
public static KCVSConfiguration getStandaloneGlobalConfiguration(final KeyColumnValueStoreManager manager,
                                                                 final Configuration config) {
    try {
        final StoreFeatures features = manager.getFeatures();
        return getGlobalConfiguration(new BackendOperation.TransactionalProvider() {
            @Override
            public StoreTransaction openTx() throws BackendException {
                return manager.beginTransaction(StandardBaseTransactionConfig.of(config.get(TIMESTAMP_PROVIDER),features.getKeyConsistentTxConfig()));
            }

            @Override
            public void close() throws BackendException {
                manager.close();
            }
        },manager.openDatabase(SYSTEM_PROPERTIES_STORE_NAME),config);
    } catch (BackendException e) {
        throw new TitanException("Could not open global configuration",e);
    }
}
 
Example 15
Project: titan1.0.1.kafka   File: StandardLogProcessorFramework.java   Source Code and License 6 votes vote down vote up
@Override
public synchronized void shutdown() throws TitanException {
    if (!isOpen) return;
    isOpen = false;
    try {
        try {
            for (Log log : processorLogs.values()) {
                log.close();
            }
            processorLogs.clear();
        } finally {
        }
    } catch (BackendException e) {
        throw new TitanException(e);
    }
}
 
Example 16
Project: titan0.5.4-hbase1.1.1-custom   File: TestMockLog.java   Source Code and License 6 votes vote down vote up
@Override
public synchronized Future<Message> add(StaticBuffer content) {
    TestMessage msg = new TestMessage(content);
    FutureMessage<TestMessage> fmsg = new FutureMessage<TestMessage>(msg);

    if (failAdds) {
        System.out.println("Failed message add");
        throw new TitanException("Log unavailable");
    }

    if (readers.isEmpty()) {
        messageBacklog.add(fmsg);
    } else {
        process(fmsg);
    }
    return fmsg;
}
 
Example 17
Project: titan0.5.4-hbase1.1.1-custom   File: ElasticSearchIndex.java   Source Code and License 6 votes vote down vote up
/**
 * If ES already contains this instance's target index, then do nothing.
 * Otherwise, create the index, then wait {@link #CREATE_SLEEP}.
 * <p>
 * The {@code client} field must point to a live, connected client.
 * The {@code indexName} field must be non-null and point to the name
 * of the index to check for existence or create.
 *
 * @param config the config for this ElasticSearchIndex
 * @throws java.lang.IllegalArgumentException if the index could not be created
 */
private void checkForOrCreateIndex(Configuration config) {
    Preconditions.checkState(null != client);

    //Create index if it does not already exist
    IndicesExistsResponse response = client.admin().indices().exists(new IndicesExistsRequest(indexName)).actionGet();
    if (!response.isExists()) {

        ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder();

        ElasticSearchSetup.applySettingsFromTitanConf(settings, config, ES_CREATE_EXTRAS_NS);

        CreateIndexResponse create = client.admin().indices().prepareCreate(indexName)
                .setSettings(settings.build()).execute().actionGet();
        try {
            final long sleep = config.get(CREATE_SLEEP);
            log.debug("Sleeping {} ms after {} index creation returned from actionGet()", sleep, indexName);
            Thread.sleep(sleep);
        } catch (InterruptedException e) {
            throw new TitanException("Interrupted while waiting for index to settle in", e);
        }
        if (!create.isAcknowledged()) throw new IllegalArgumentException("Could not create index: " + indexName);
    }
}
 
Example 18
Project: titan0.5.4-hbase1.1.1-custom   File: ExpirationKCVSCache.java   Source Code and License 6 votes vote down vote up
@Override
public EntryList getSlice(final KeySliceQuery query, final StoreTransaction txh) throws BackendException {
    incActionBy(1, CacheMetricsAction.RETRIEVAL,txh);
    if (isExpired(query)) {
        incActionBy(1, CacheMetricsAction.MISS,txh);
        return store.getSlice(query, unwrapTx(txh));
    }

    try {
        return cache.get(query,new Callable<EntryList>() {
            @Override
            public EntryList call() throws Exception {
                incActionBy(1, CacheMetricsAction.MISS,txh);
                return store.getSlice(query, unwrapTx(txh));
            }
        });
    } catch (Exception e) {
        if (e instanceof TitanException) throw (TitanException)e;
        else if (e.getCause() instanceof TitanException) throw (TitanException)e.getCause();
        else throw new TitanException(e);
    }
}
 
Example 19
Project: titan0.5.4-hbase1.1.1-custom   File: Backend.java   Source Code and License 6 votes vote down vote up
public static KCVSConfiguration getStandaloneGlobalConfiguration(final KeyColumnValueStoreManager manager,
                                                                 final Configuration config) {
    try {
        final StoreFeatures features = manager.getFeatures();
        return getGlobalConfiguration(new BackendOperation.TransactionalProvider() {
            @Override
            public StoreTransaction openTx() throws BackendException {
                return manager.beginTransaction(StandardBaseTransactionConfig.of(config.get(TIMESTAMP_PROVIDER),features.getKeyConsistentTxConfig()));
            }

            @Override
            public void close() throws BackendException {
                manager.close();
            }
        },manager.openDatabase(SYSTEM_PROPERTIES_STORE_NAME),config);
    } catch (BackendException e) {
        throw new TitanException("Could not open global configuration",e);
    }
}
 
Example 20
Project: titan0.5.4-hbase1.1.1-custom   File: StandardSerializer.java   Source Code and License 6 votes vote down vote up
private DataOutput writeObjectNotNullInternal(Object object, boolean byteOrder) {
    Preconditions.checkNotNull(object);
    AttributeSerializer s = getSerializer(object.getClass());
    if (byteOrder) {
        Preconditions.checkArgument(s!=null && s instanceof OrderPreservingSerializer,"Invalid serializer for class: %s",object.getClass());
        ((OrderPreservingSerializer)s).writeByteOrder(this,object);
    } else {
        if (s!=null) s.write(this, object);
        else {
            try {
                getBackupSerializer().writeObjectNotNull(this,object);
            } catch (Exception e) {
                throw new TitanException("Serializer Restriction: Cannot serialize object of type: " + object.getClass(),e);
            }
        }
    }
    return this;
}
 
Example 21
Project: titan0.5.4-hbase1.1.1-custom   File: StandardLogProcessorFramework.java   Source Code and License 6 votes vote down vote up
@Override
public synchronized void shutdown() throws TitanException {
    if (!isOpen) return;
    isOpen = false;
    try {
        try {
            for (Log log : processorLogs.values()) {
                log.close();
            }
            processorLogs.clear();
        } finally {
        }
    } catch (BackendException e) {
        throw new TitanException(e);
    }
}
 
Example 22
Project: titan1withtp3.1   File: IDPoolTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testAllocationTimeout() {
    final MockIDAuthority idauth = new MockIDAuthority(10000, Integer.MAX_VALUE, 5000);
    StandardIDPool pool = new StandardIDPool(idauth, 1, 1, Integer.MAX_VALUE, Duration.ofMillis(4000), 0.1);
    try {
        pool.nextID();
        fail();
    } catch (TitanException e) {

    }

}
 
Example 23
Project: titan1withtp3.1   File: ExternalCachePersistor.java   Source Code and License 5 votes vote down vote up
@Override
public void add(StaticBuffer key, Entry cell) {
    try {
        kcvs.mutateEntries(key, Lists.newArrayList(cell), KCVSCache.NO_DELETIONS,tx);
    } catch (BackendException e) {
        throw new TitanException("Unexpected storage exception in log persistence against cache",e);
    }
}
 
Example 24
Project: titan1withtp3.1   File: KCVSConfiguration.java   Source Code and License 5 votes vote down vote up
@Override
public void close() {
    try {
        store.close();
        txProvider.close();
        IOUtils.closeQuietly(serializer);
    } catch (BackendException e) {
        throw new TitanException("Could not close configuration store",e);
    }
}
 
Example 25
Project: titan1withtp3.1   File: Backend.java   Source Code and License 5 votes vote down vote up
public KCVSLog getSystemTxLog() {
    try {
        return txLogManager.openLog(SYSTEM_TX_LOG_NAME);
    } catch (BackendException e) {
        throw new TitanException("Could not re-open transaction log", e);
    }
}
 
Example 26
Project: titan1withtp3.1   File: Backend.java   Source Code and License 5 votes vote down vote up
public Log getSystemMgmtLog() {
    try {
        return mgmtLogManager.openLog(SYSTEM_MGMT_LOG_NAME);
    } catch (BackendException e) {
        throw new TitanException("Could not re-open management log", e);
    }
}
 
Example 27
Project: titan1withtp3.1   File: Backend.java   Source Code and License 5 votes vote down vote up
private static KCVSConfiguration getConfiguration(final BackendOperation.TransactionalProvider txProvider,
                                                        final KeyColumnValueStore store, final String identifier,
                                                        final Configuration config) {
    try {
        KCVSConfiguration kcvsConfig =
                new KCVSConfiguration(txProvider,config,store,identifier);
        kcvsConfig.setMaxOperationWaitTime(config.get(SETUP_WAITTIME));
        return kcvsConfig;
    } catch (BackendException e) {
        throw new TitanException("Could not open global configuration",e);
    }
}
 
Example 28
Project: titan1withtp3.1   File: BackendOperation.java   Source Code and License 5 votes vote down vote up
public static final<V> V execute(Callable<V> exe, Duration totalWaitTime) throws TitanException {
    try {
        return executeDirect(exe,totalWaitTime);
    } catch (BackendException e) {
        throw new TitanException("Could not execute operation due to backend exception",e);
    }
}
 
Example 29
Project: titan1withtp3.1   File: BackendOperation.java   Source Code and License 5 votes vote down vote up
public static<R> R execute(final Transactional<R> exe, final TransactionalProvider provider, final TimestampProvider times, Duration maxTime) throws TitanException {
    return execute(new Callable<R>() {
        @Override
        public R call() throws Exception {
            return execute(exe,provider,times);
        }
        @Override
        public String toString() {
            return exe.toString();
        }
    },maxTime);
}
 
Example 30
Project: titan1withtp3.1   File: ReentrantTransactionLock.java   Source Code and License 5 votes vote down vote up
@Override
public void lock(Duration timeout) {
    boolean success = false;
    try {
        success = super.tryLock(timeout.toNanos(), TimeUnit.NANOSECONDS);
    } catch (InterruptedException e) {
        log.warn("Interrupted waiting for lock: {}",e);
    }
    if (!success) throw new TitanException("Possible dead lock detected. Waited for transaction lock without success");
}
 
Example 31
Project: titan1withtp3.1   File: ManagementSystem.java   Source Code and License 5 votes vote down vote up
@Override
public void addIndexKey(final TitanGraphIndex index, final PropertyKey key, Parameter... parameters) {
    Preconditions.checkArgument(index != null && key != null && index instanceof TitanGraphIndexWrapper
            && !(key instanceof BaseKey), "Need to provide valid index and key");
    if (parameters == null) parameters = new Parameter[0];
    IndexType indexType = ((TitanGraphIndexWrapper) index).getBaseIndex();
    Preconditions.checkArgument(indexType instanceof MixedIndexType, "Can only add keys to an external index, not %s", index.name());
    Preconditions.checkArgument(indexType instanceof IndexTypeWrapper && key instanceof TitanSchemaVertex
            && ((IndexTypeWrapper) indexType).getSchemaBase() instanceof TitanSchemaVertex);

    TitanSchemaVertex indexVertex = (TitanSchemaVertex) ((IndexTypeWrapper) indexType).getSchemaBase();

    for (IndexField field : indexType.getFieldKeys())
        Preconditions.checkArgument(!field.getFieldKey().equals(key), "Key [%s] has already been added to index %s", key.name(), index.name());

    //Assemble parameters
    boolean addMappingParameter = !ParameterType.MAPPED_NAME.hasParameter(parameters);
    Parameter[] extendedParas = new Parameter[parameters.length + 1 + (addMappingParameter ? 1 : 0)];
    System.arraycopy(parameters, 0, extendedParas, 0, parameters.length);
    int arrPosition = parameters.length;
    if (addMappingParameter) extendedParas[arrPosition++] = ParameterType.MAPPED_NAME.getParameter(
            graph.getIndexSerializer().getDefaultFieldName(key, parameters, indexType.getBackingIndexName()));
    extendedParas[arrPosition++] = ParameterType.STATUS.getParameter(key.isNew() ? SchemaStatus.ENABLED : SchemaStatus.INSTALLED);

    addSchemaEdge(indexVertex, key, TypeDefinitionCategory.INDEX_FIELD, extendedParas);
    updateSchemaVertex(indexVertex);
    indexType.resetCache();
    //Check to see if the index supports this
    if (!graph.getIndexSerializer().supports((MixedIndexType) indexType, ParameterIndexField.of(key, parameters))) {
        throw new TitanException("Could not register new index field '" + key.name() + "' with index backend as the data type, cardinality or parameter combination is not supported.");
    }

    try {
        IndexSerializer.register((MixedIndexType) indexType, key, transaction.getTxHandle());
    } catch (BackendException e) {
        throw new TitanException("Could not register new index field with index backend", e);
    }
    if (!indexVertex.isNew()) updatedTypes.add(indexVertex);
    if (!key.isNew()) updateIndex(index, SchemaAction.REGISTER_INDEX);
}
 
Example 32
Project: titan1withtp3.1   File: StandardLogProcessorFramework.java   Source Code and License 5 votes vote down vote up
@Override
public synchronized boolean removeLogProcessor(String logIdentifier) {
    checkOpen();
    if (processorLogs.containsKey(logIdentifier)) {
        try {
            processorLogs.get(logIdentifier).close();
        } catch (BackendException e) {
            throw new TitanException("Could not close transaction log: "+ logIdentifier,e);
        }
        processorLogs.remove(logIdentifier);
        return true;
    } else return false;
}
 
Example 33
Project: titan1withtp3.1   File: StandardLogProcessorFramework.java   Source Code and License 5 votes vote down vote up
@Override
public void build() {
    Preconditions.checkArgument(!processors.isEmpty(),"Must add at least one processor");
    ReadMarker readMarker;
    if (startTime==null && readMarkerName==null) {
        readMarker = ReadMarker.fromNow();
    } else if (readMarkerName==null) {
        readMarker = ReadMarker.fromTime(startTime);
    } else if (startTime==null) {
        readMarker = ReadMarker.fromIdentifierOrNow(readMarkerName);
    } else {
        readMarker = ReadMarker.fromIdentifierOrTime(readMarkerName, startTime);
    }
    synchronized (StandardLogProcessorFramework.this) {
        Preconditions.checkArgument(!processorLogs.containsKey(userLogName),
                "Processors have already been registered for user log: %s",userLogName);
        try {
            Log log = graph.getBackend().getUserLog(userLogName);
            log.registerReaders(readMarker,Iterables.transform(processors, new Function<ChangeProcessor, MessageReader>() {
                @Nullable
                @Override
                public MessageReader apply(@Nullable ChangeProcessor changeProcessor) {
                    return new MsgReaderConverter(userLogName, changeProcessor, retryAttempts);
                }
            }));
        } catch (BackendException e) {
            throw new TitanException("Could not open user transaction log for name: "+ userLogName,e);
        }
    }
}
 
Example 34
Project: titan1withtp3.1   File: IndexUpdateJob.java   Source Code and License 5 votes vote down vote up
public void workerIterationStart(TitanGraph graph, Configuration config, ScanMetrics metrics) {
    this.graph = (StandardTitanGraph)graph;
    Preconditions.checkArgument(config.has(GraphDatabaseConfiguration.JOB_START_TIME),"Invalid configuration for this job. Start time is required.");
    this.jobStartTime = Instant.ofEpochMilli(config.get(GraphDatabaseConfiguration.JOB_START_TIME));
    if (indexName == null) {
        Preconditions.checkArgument(config.has(INDEX_NAME), "Need to configure the name of the index to be repaired");
        indexName = config.get(INDEX_NAME);
        indexRelationTypeName = config.get(INDEX_RELATION_TYPE);
        log.info("Read index information: name={} type={}", indexName, indexRelationTypeName);
    }

    try {
        this.mgmt = (ManagementSystem)graph.openManagement();

        if (isGlobalGraphIndex()) {
            index = mgmt.getGraphIndex(indexName);
        } else {
            indexRelationType = mgmt.getRelationType(indexRelationTypeName);
            Preconditions.checkArgument(indexRelationType!=null,"Could not find relation type: %s", indexRelationTypeName);
            index = mgmt.getRelationIndex(indexRelationType,indexName);
        }
        Preconditions.checkArgument(index!=null,"Could not find index: %s [%s]",indexName,indexRelationTypeName);
        log.info("Found index {}", indexName);
        validateIndexStatus();

        StandardTransactionBuilder txb = this.graph.buildTransaction();
        txb.commitTime(jobStartTime);
        writeTx = (StandardTitanTx)txb.start();
    } catch (final Exception e) {
        if (null != mgmt && mgmt.isOpen())
            mgmt.rollback();
        if (writeTx!=null && writeTx.isOpen())
            writeTx.rollback();
        metrics.incrementCustom(FAILED_TX);
        throw new TitanException(e.getMessage(), e);
    }
}
 
Example 35
Project: titan1withtp3.1   File: HBaseStoreManager.java   Source Code and License 5 votes vote down vote up
private AdminMask getAdminInterface() {
    try {
        return cnx.getAdmin();
    } catch (IOException e) {
        throw new TitanException(e);
    }
}
 
Example 36
Project: incubator-atlas   File: HBaseStoreManager.java   Source Code and License 5 votes vote down vote up
private AdminMask getAdminInterface() {
    try {
        return cnx.getAdmin();
    } catch (IOException e) {
        throw new TitanException(e);
    }
}
 
Example 37
Project: titan1.0.1.kafka   File: IDPoolTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testAllocationTimeout() {
    final MockIDAuthority idauth = new MockIDAuthority(10000, Integer.MAX_VALUE, 5000);
    StandardIDPool pool = new StandardIDPool(idauth, 1, 1, Integer.MAX_VALUE, Duration.ofMillis(4000), 0.1);
    try {
        pool.nextID();
        fail();
    } catch (TitanException e) {

    }

}
 
Example 38
Project: titan1.0.1.kafka   File: ExternalCachePersistor.java   Source Code and License 5 votes vote down vote up
@Override
public void add(StaticBuffer key, Entry cell) {
    try {
        kcvs.mutateEntries(key, Lists.newArrayList(cell), KCVSCache.NO_DELETIONS,tx);
    } catch (BackendException e) {
        throw new TitanException("Unexpected storage exception in log persistence against cache",e);
    }
}
 
Example 39
Project: titan1.0.1.kafka   File: KCVSConfiguration.java   Source Code and License 5 votes vote down vote up
@Override
public void close() {
    try {
        store.close();
        txProvider.close();
        IOUtils.closeQuietly(serializer);
    } catch (BackendException e) {
        throw new TitanException("Could not close configuration store",e);
    }
}
 
Example 40
Project: titan1.0.1.kafka   File: Backend.java   Source Code and License 5 votes vote down vote up
public KCVSLog getSystemTxLog() {
    try {
        return txLogManager.openLog(SYSTEM_TX_LOG_NAME);
    } catch (BackendException e) {
        throw new TitanException("Could not re-open transaction log", e);
    }
}