Java Code Examples for org.apache.accumulo.core.client.BatchWriterConfig#setTimeout()

The following examples show how to use org.apache.accumulo.core.client.BatchWriterConfig#setTimeout() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BatchWriterOpts.java    From accumulo-examples with Apache License 2.0 5 votes vote down vote up
public BatchWriterConfig getBatchWriterConfig() {
  BatchWriterConfig config = new BatchWriterConfig();
  config.setMaxWriteThreads(this.batchThreads);
  config.setMaxLatency(this.batchLatency, TimeUnit.MILLISECONDS);
  config.setMaxMemory(this.batchMemory);
  config.setTimeout(this.batchTimeout, TimeUnit.MILLISECONDS);
  return config;
}
 
Example 2
Source File: AccumuloGraphConfiguration.java    From vertexium with Apache License 2.0 5 votes vote down vote up
public BatchWriterConfig createBatchWriterConfig() {
    long maxMemory = getConfigLong(BATCHWRITER_MAX_MEMORY, DEFAULT_BATCHWRITER_MAX_MEMORY);
    long maxLatency = getConfigLong(BATCHWRITER_MAX_LATENCY, DEFAULT_BATCHWRITER_MAX_LATENCY);
    int maxWriteThreads = getInt(BATCHWRITER_MAX_WRITE_THREADS, DEFAULT_BATCHWRITER_MAX_WRITE_THREADS);
    long timeout = getConfigLong(BATCHWRITER_TIMEOUT, DEFAULT_BATCHWRITER_TIMEOUT);

    BatchWriterConfig config = new BatchWriterConfig();
    config.setMaxMemory(maxMemory);
    config.setMaxLatency(maxLatency, TimeUnit.MILLISECONDS);
    config.setMaxWriteThreads(maxWriteThreads);
    config.setTimeout(timeout, TimeUnit.MILLISECONDS);
    return config;
}
 
Example 3
Source File: RyaOutputFormat.java    From rya with Apache License 2.0 4 votes vote down vote up
/**
 * Constructor.
 * @param conf Configuration containing any relevant options.
 * @throws  IOException if the core Rya indexer or entity indexer can't
 *          be initialized
 */
public RyaRecordWriter(final Configuration conf) throws IOException {
    // set the visibility
    final String visibility = conf.get(CV_PROPERTY);
    if (visibility != null) {
        cv = visibility.getBytes(StandardCharsets.UTF_8);
    }
    // set the default context
    final String context = conf.get(CONTEXT_PROPERTY, "");
    if (context != null && !context.isEmpty()) {
        defaultContext = new RyaIRI(context);
    }

    // set up the buffer
    bufferSizeLimit = conf.getLong(MAX_MUTATION_BUFFER_SIZE, ONE_MEGABYTE);
    final int bufferCapacity = (int) (bufferSizeLimit / AVE_STATEMENT_SIZE);
    buffer = new ArrayList<RyaStatement>(bufferCapacity);

    // set up the indexers
    freeTextIndexer = getFreeTextIndexer(conf);
    temporalIndexer = getTemporalIndexer(conf);
    entityIndexer = getEntityIndexer(conf);
    ryaIndexer = getRyaIndexer(conf);

    // The entity index needs a batch writer -- typically it uses the DAO's, but decoupling
    // them lets it be used with or without the core tables, like the other indexers.
    if (entityIndexer != null) {
        Connector conn;
        try {
            conn = ConfigUtils.getConnector(conf);
        } catch (AccumuloException | AccumuloSecurityException e) {
            throw new IOException("Error connecting to Accumulo for entity index output", e);
        }
        final BatchWriterConfig batchWriterConfig = new BatchWriterConfig();
        batchWriterConfig.setMaxMemory(RdfCloudTripleStoreConstants.MAX_MEMORY);
        batchWriterConfig.setTimeout(RdfCloudTripleStoreConstants.MAX_TIME, TimeUnit.MILLISECONDS);
        batchWriterConfig.setMaxWriteThreads(RdfCloudTripleStoreConstants.NUM_THREADS);
        writer = conn.createMultiTableBatchWriter(batchWriterConfig);
        entityIndexer.setMultiTableBatchWriter(writer);
    }

    // update fields used for metrics
    startTime = System.currentTimeMillis();
    lastCommitFinishTime = startTime;

    // set up the triple context
    tripleContext = RyaTripleContext.getInstance(new AccumuloRdfConfiguration(conf));
}