You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@rya.apache.org by meiercaleb <gi...@git.apache.org> on 2017/08/22 20:08:06 UTC

[GitHub] incubator-rya pull request #149: RYA-266 Added calls to init() where-ever th...

Github user meiercaleb commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/149#discussion_r134584063
  
    --- Diff: extras/indexing/src/main/java/org/apache/rya/indexing/accumulo/temporal/AccumuloTemporalIndexer.java ---
    @@ -102,42 +103,50 @@
         private boolean isInit = false;
     
     
    +    /**
    +     * intilize the temporal index.
    +     * This is dependent on a few set method calls before init:
    +     * >  Connector = ConfigUtils.getConnector(conf);
    +     * >  MultiTableBatchWriter mtbw = connector.createMultiTableBatchWriter(new BatchWriterConfig());
    +     * >  // optional: temporal.setConnector(connector);
    +     * >  temporal.setMultiTableBatchWriter(mtbw);
    +     * >  temporal.init();
    +     */
    +    @Override
    +    public void init() {
    +        if (!isInit) {
    +            try {
    +                initInternal();
    +                isInit = true;
    +            } catch (final AccumuloException | AccumuloSecurityException | TableNotFoundException | TableExistsException | RyaClientException e) {
    +                logger.warn("Unable to initialize index.  Throwing Runtime Exception. ", e);
    +                throw new RuntimeException(e);
    +            }
    +        }
    +    }
     
         private void initInternal() throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
    -            TableExistsException {
    +                    TableExistsException, RyaClientException {
    +        if (mtbw == null)
    +            throw new RyaClientException("Failed to initialize temporal index, setMultiTableBatchWriter() was not set.");
    +        if (conf == null)
    +            throw new RyaClientException("Failed to initialize temporal index, setConf() was not set.");
    +
             temporalIndexTableName = getTableName();
             // Create one index table on first run.
    -        ConfigUtils.createTableIfNotExists(conf, temporalIndexTableName);
    -
    -        mtbw = ConfigUtils.createMultitableBatchWriter(conf);
    -
    +        Boolean isCreated = ConfigUtils.createTableIfNotExists(conf, temporalIndexTableName);
    +        if (isCreated) {
    +            logger.info("First run, created temporal index table: " + temporalIndexTableName);
    +        }
             temporalIndexBatchWriter = mtbw.getBatchWriter(temporalIndexTableName);
    -
             validPredicates = ConfigUtils.getTemporalPredicates(conf);
         }
     
         //initialization occurs in setConf because index is created using reflection
         @Override
         public void setConf(final Configuration conf) {
             this.conf = conf;
    -        if (!isInit) {
    --- End diff --
    
    Unfortunately, you cannot delete this method.  This is how we initialize our Indices when they are created via reflection in the AccumuloRyaDAO.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---