Java Code Examples for com.thinkaurelius.titan.diskstorage.configuration.ConfigElement

The following are top voted examples for showing how to use com.thinkaurelius.titan.diskstorage.configuration.ConfigElement. 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: titan1withtp3.1   File: CassandraGraphTest.java   View source code 6 votes vote down vote up
@Test
public void testGraphConfigUsedByThreadBoundTx() {
    close();
    WriteConfiguration wc = getConfiguration();
    wc.set(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "ALL");
    wc.set(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "LOCAL_QUORUM");

    graph = (StandardTitanGraph) TitanFactory.open(wc);

    StandardTitanTx tx = (StandardTitanTx)graph.getCurrentThreadTx();
    assertEquals("ALL",
            tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
                    .get(AbstractCassandraStoreManager.CASSANDRA_READ_CONSISTENCY));
    assertEquals("LOCAL_QUORUM",
            tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
                    .get(AbstractCassandraStoreManager.CASSANDRA_WRITE_CONSISTENCY));
}
 
Example 2
Project: titan1withtp3.1   File: CassandraGraphTest.java   View source code 6 votes vote down vote up
@Test
public void testGraphConfigUsedByTx() {
    close();
    WriteConfiguration wc = getConfiguration();
    wc.set(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "TWO");
    wc.set(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "THREE");

    graph = (StandardTitanGraph) TitanFactory.open(wc);

    StandardTitanTx tx = (StandardTitanTx)graph.newTransaction();
    assertEquals("TWO",
            tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
                    .get(AbstractCassandraStoreManager.CASSANDRA_READ_CONSISTENCY));
    assertEquals("THREE",
            tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
                    .get(AbstractCassandraStoreManager.CASSANDRA_WRITE_CONSISTENCY));
    tx.rollback();
}
 
Example 3
Project: titan1withtp3.1   File: CassandraGraphTest.java   View source code 6 votes vote down vote up
@Test
public void testCustomConfigUsedByTx() {
    close();
    WriteConfiguration wc = getConfiguration();
    wc.set(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "ALL");
    wc.set(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "ALL");

    graph = (StandardTitanGraph) TitanFactory.open(wc);

    StandardTitanTx tx = (StandardTitanTx)graph.buildTransaction()
            .customOption(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "ONE")
            .customOption(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "TWO").start();

    assertEquals("ONE",
            tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
                    .get(AbstractCassandraStoreManager.CASSANDRA_READ_CONSISTENCY));
    assertEquals("TWO",
            tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
                    .get(AbstractCassandraStoreManager.CASSANDRA_WRITE_CONSISTENCY));
    tx.rollback();
}
 
Example 4
Project: titan1withtp3.1   File: MapReduceIndexManagement.java   View source code 6 votes vote down vote up
private static void copyInputKeys(org.apache.hadoop.conf.Configuration hadoopConf, org.apache.commons.configuration.Configuration source) {
    // Copy IndexUpdateJob settings into the hadoop-backed cfg
    Iterator<String> keyIter = source.getKeys();
    while (keyIter.hasNext()) {
        String key = keyIter.next();
        ConfigElement.PathIdentifier pid;
        try {
            pid = ConfigElement.parse(ROOT_NS, key);
        } catch (RuntimeException e) {
            log.debug("[inputkeys] Skipping {}", key, e);
            continue;
        }

        if (!pid.element.isOption())
            continue;

        String k = ConfigElement.getPath(TitanHadoopConfiguration.GRAPH_CONFIG_KEYS, true) + "." + key;
        String v = source.getProperty(key).toString();

        hadoopConf.set(k, v);
        log.debug("[inputkeys] Set {}={}", k, v);
    }
}
 
Example 5
Project: titan1withtp3.1   File: HBaseHadoopScanRunner.java   View source code 6 votes vote down vote up
public ScanMetrics run() throws InterruptedException, IOException, ClassNotFoundException {

        org.apache.hadoop.conf.Configuration hadoopConf = null != baseHadoopConf ?
                baseHadoopConf : new org.apache.hadoop.conf.Configuration();

        if (null != titanConf) {
            String prefix = ConfigElement.getPath(TitanHadoopConfiguration.GRAPH_CONFIG_KEYS, true) + ".";
            for (String k : titanConf.getKeys("")) {
                hadoopConf.set(prefix + k, titanConf.get(k, Object.class).toString());
                log.debug("Set: {}={}", prefix + k, titanConf.get(k, Object.class).toString());
            }
        }
        Preconditions.checkNotNull(hadoopConf);

        if (null != scanJob) {
            return HadoopScanRunner.runScanJob(scanJob, scanJobConf, scanJobConfRoot, hadoopConf, HBaseBinaryInputFormat.class);
        } else {
            return HadoopScanRunner.runVertexScanJob(vertexScanJob, scanJobConf, scanJobConfRoot, hadoopConf, HBaseBinaryInputFormat.class);
        }
    }
 
Example 6
Project: titan1withtp3.1   File: ConfigurationPrinter.java   View source code 6 votes vote down vote up
@SuppressWarnings("unchecked")
private <E> List<E> getSortedChildren(ConfigNamespace n, Function<ConfigElement, Boolean> predicate) {
    List<ConfigElement> sortedElements = new ArrayList<ConfigElement>();

    for (ConfigElement e : n.getChildren()) {
        if (predicate.apply(e)) {
            sortedElements.add(e);
        }
    }
    Collections.sort(sortedElements, new Comparator<ConfigElement>() {
        @Override
        public int compare(ConfigElement o1, ConfigElement o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });

    return (List<E>)sortedElements;
}
 
Example 7
Project: titan1.0.1.kafka   File: CassandraGraphTest.java   View source code 6 votes vote down vote up
@Test
public void testGraphConfigUsedByThreadBoundTx() {
    close();
    WriteConfiguration wc = getConfiguration();
    wc.set(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "ALL");
    wc.set(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "LOCAL_QUORUM");

    graph = (StandardTitanGraph) TitanFactory.open(wc);

    StandardTitanTx tx = (StandardTitanTx)graph.getCurrentThreadTx();
    assertEquals("ALL",
            tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
                    .get(AbstractCassandraStoreManager.CASSANDRA_READ_CONSISTENCY));
    assertEquals("LOCAL_QUORUM",
            tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
                    .get(AbstractCassandraStoreManager.CASSANDRA_WRITE_CONSISTENCY));
}
 
Example 8
Project: titan1.0.1.kafka   File: CassandraGraphTest.java   View source code 6 votes vote down vote up
@Test
public void testGraphConfigUsedByTx() {
    close();
    WriteConfiguration wc = getConfiguration();
    wc.set(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "TWO");
    wc.set(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "THREE");

    graph = (StandardTitanGraph) TitanFactory.open(wc);

    StandardTitanTx tx = (StandardTitanTx)graph.newTransaction();
    assertEquals("TWO",
            tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
                    .get(AbstractCassandraStoreManager.CASSANDRA_READ_CONSISTENCY));
    assertEquals("THREE",
            tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
                    .get(AbstractCassandraStoreManager.CASSANDRA_WRITE_CONSISTENCY));
    tx.rollback();
}
 
Example 9
Project: titan1.0.1.kafka   File: CassandraGraphTest.java   View source code 6 votes vote down vote up
@Test
public void testCustomConfigUsedByTx() {
    close();
    WriteConfiguration wc = getConfiguration();
    wc.set(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "ALL");
    wc.set(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "ALL");

    graph = (StandardTitanGraph) TitanFactory.open(wc);

    StandardTitanTx tx = (StandardTitanTx)graph.buildTransaction()
            .customOption(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "ONE")
            .customOption(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "TWO").start();

    assertEquals("ONE",
            tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
                    .get(AbstractCassandraStoreManager.CASSANDRA_READ_CONSISTENCY));
    assertEquals("TWO",
            tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
                    .get(AbstractCassandraStoreManager.CASSANDRA_WRITE_CONSISTENCY));
    tx.rollback();
}
 
Example 10
Project: titan1.0.1.kafka   File: MapReduceIndexManagement.java   View source code 6 votes vote down vote up
private static void copyInputKeys(org.apache.hadoop.conf.Configuration hadoopConf, org.apache.commons.configuration.Configuration source) {
    // Copy IndexUpdateJob settings into the hadoop-backed cfg
    Iterator<String> keyIter = source.getKeys();
    while (keyIter.hasNext()) {
        String key = keyIter.next();
        ConfigElement.PathIdentifier pid;
        try {
            pid = ConfigElement.parse(ROOT_NS, key);
        } catch (RuntimeException e) {
            log.debug("[inputkeys] Skipping {}", key, e);
            continue;
        }

        if (!pid.element.isOption())
            continue;

        String k = ConfigElement.getPath(TitanHadoopConfiguration.GRAPH_CONFIG_KEYS, true) + "." + key;
        String v = source.getProperty(key).toString();

        hadoopConf.set(k, v);
        log.debug("[inputkeys] Set {}={}", k, v);
    }
}
 
Example 11
Project: titan1.0.1.kafka   File: HBaseHadoopScanRunner.java   View source code 6 votes vote down vote up
public ScanMetrics run() throws InterruptedException, IOException, ClassNotFoundException {

        org.apache.hadoop.conf.Configuration hadoopConf = null != baseHadoopConf ?
                baseHadoopConf : new org.apache.hadoop.conf.Configuration();

        if (null != titanConf) {
            String prefix = ConfigElement.getPath(TitanHadoopConfiguration.GRAPH_CONFIG_KEYS, true) + ".";
            for (String k : titanConf.getKeys("")) {
                hadoopConf.set(prefix + k, titanConf.get(k, Object.class).toString());
                log.debug("Set: {}={}", prefix + k, titanConf.get(k, Object.class).toString());
            }
        }
        Preconditions.checkNotNull(hadoopConf);

        if (null != scanJob) {
            return HadoopScanRunner.runScanJob(scanJob, scanJobConf, scanJobConfRoot, hadoopConf, HBaseBinaryInputFormat.class);
        } else {
            return HadoopScanRunner.runVertexScanJob(vertexScanJob, scanJobConf, scanJobConfRoot, hadoopConf, HBaseBinaryInputFormat.class);
        }
    }
 
Example 12
Project: titan1.0.1.kafka   File: ConfigurationPrinter.java   View source code 6 votes vote down vote up
@SuppressWarnings("unchecked")
private <E> List<E> getSortedChildren(ConfigNamespace n, Function<ConfigElement, Boolean> predicate) {
    List<ConfigElement> sortedElements = new ArrayList<ConfigElement>();

    for (ConfigElement e : n.getChildren()) {
        if (predicate.apply(e)) {
            sortedElements.add(e);
        }
    }
    Collections.sort(sortedElements, new Comparator<ConfigElement>() {
        @Override
        public int compare(ConfigElement o1, ConfigElement o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });

    return (List<E>)sortedElements;
}
 
Example 13
Project: titan0.5.4-hbase1.1.1-custom   File: CassandraGraphTest.java   View source code 6 votes vote down vote up
@Test
public void testGraphConfigUsedByThreadBoundTx() {
    close();
    WriteConfiguration wc = getConfiguration();
    wc.set(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "ALL");
    wc.set(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "LOCAL_QUORUM");

    graph = (StandardTitanGraph) TitanFactory.open(wc);

    StandardTitanTx tx = (StandardTitanTx)graph.getCurrentThreadTx();
    assertEquals("ALL",
            tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
                    .get(AbstractCassandraStoreManager.CASSANDRA_READ_CONSISTENCY));
    assertEquals("LOCAL_QUORUM",
            tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
                    .get(AbstractCassandraStoreManager.CASSANDRA_WRITE_CONSISTENCY));
}
 
Example 14
Project: titan0.5.4-hbase1.1.1-custom   File: CassandraGraphTest.java   View source code 6 votes vote down vote up
@Test
public void testGraphConfigUsedByTx() {
    close();
    WriteConfiguration wc = getConfiguration();
    wc.set(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "TWO");
    wc.set(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "THREE");

    graph = (StandardTitanGraph) TitanFactory.open(wc);

    StandardTitanTx tx = (StandardTitanTx)graph.newTransaction();
    assertEquals("TWO",
            tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
                    .get(AbstractCassandraStoreManager.CASSANDRA_READ_CONSISTENCY));
    assertEquals("THREE",
            tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
                    .get(AbstractCassandraStoreManager.CASSANDRA_WRITE_CONSISTENCY));
    tx.rollback();
}
 
Example 15
Project: titan0.5.4-hbase1.1.1-custom   File: CassandraGraphTest.java   View source code 6 votes vote down vote up
@Test
public void testCustomConfigUsedByTx() {
    close();
    WriteConfiguration wc = getConfiguration();
    wc.set(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "ALL");
    wc.set(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "ALL");

    graph = (StandardTitanGraph) TitanFactory.open(wc);

    StandardTitanTx tx = (StandardTitanTx)graph.buildTransaction()
            .setCustomOption(ConfigElement.getPath(CASSANDRA_READ_CONSISTENCY), "ONE")
            .setCustomOption(ConfigElement.getPath(CASSANDRA_WRITE_CONSISTENCY), "TWO").start();

    assertEquals("ONE",
            tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
                    .get(AbstractCassandraStoreManager.CASSANDRA_READ_CONSISTENCY));
    assertEquals("TWO",
            tx.getTxHandle().getBaseTransactionConfig().getCustomOptions()
                    .get(AbstractCassandraStoreManager.CASSANDRA_WRITE_CONSISTENCY));
    tx.rollback();
}
 
Example 16
Project: titan0.5.4-hbase1.1.1-custom   File: ConfigurationPrinter.java   View source code 6 votes vote down vote up
@SuppressWarnings("unchecked")
private <E> List<E> getSortedChildren(ConfigNamespace n, Function<ConfigElement, Boolean> predicate) {
    List<ConfigElement> sortedElements = new ArrayList<ConfigElement>();

    for (ConfigElement e : n.getChildren()) {
        if (predicate.apply(e)) {
            sortedElements.add(e);
        }
    }
    Collections.sort(sortedElements, new Comparator<ConfigElement>() {
        @Override
        public int compare(ConfigElement o1, ConfigElement o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });

    return (List<E>)sortedElements;
}
 
Example 17
Project: titan1withtp3.1   File: AbstractTitanGraphProvider.java   View source code 5 votes vote down vote up
@Override
public Map<String, Object> getBaseConfiguration(String graphName, Class<?> test, String testMethodName, final LoadGraphWith.GraphData loadGraphWith) {
    ModifiableConfiguration conf = getTitanConfiguration(graphName, test, testMethodName);
    conf.set(GraphDatabaseConfiguration.COMPUTER_RESULT_MODE, "persist");
    conf.set(GraphDatabaseConfiguration.AUTO_TYPE, "tp3");
    Map<String, Object> result = new HashMap<>();
    conf.getAll().entrySet().stream().forEach(e -> result.put(ConfigElement.getPath(e.getKey().element, e.getKey().umbrellaElements), e.getValue()));
    result.put(Graph.GRAPH, TitanFactory.class.getName());
    return result;
}
 
Example 18
Project: titan1withtp3.1   File: BerkeleyGraphTest.java   View source code 5 votes vote down vote up
@Override
public void testConsistencyEnforcement() {
    // Check that getConfiguration() explicitly set serializable isolation
    // This could be enforced with a JUnit assertion instead of a Precondition,
    // but a failure here indicates a problem in the test itself rather than the
    // system-under-test, so a Precondition seems more appropriate
    IsolationLevel effective = ConfigOption.getEnumValue(config.get(ConfigElement.getPath(BerkeleyJEStoreManager.ISOLATION_LEVEL), String.class),IsolationLevel.class);
    Preconditions.checkState(IsolationLevel.SERIALIZABLE.equals(effective));
    super.testConsistencyEnforcement();
}
 
Example 19
Project: titan1withtp3.1   File: MapReduceIndexManagement.java   View source code 5 votes vote down vote up
private static void copyIndexJobKeys(org.apache.hadoop.conf.Configuration hadoopConf, String indexName, String relationType) {
    hadoopConf.set(ConfigElement.getPath(TitanHadoopConfiguration.SCAN_JOB_CONFIG_KEYS, true) + "." +
                    ConfigElement.getPath(IndexUpdateJob.INDEX_NAME), indexName);

    hadoopConf.set(ConfigElement.getPath(TitanHadoopConfiguration.SCAN_JOB_CONFIG_KEYS, true) + "." +
            ConfigElement.getPath(IndexUpdateJob.INDEX_RELATION_TYPE), relationType);

    hadoopConf.set(ConfigElement.getPath(TitanHadoopConfiguration.SCAN_JOB_CONFIG_KEYS, true) + "." +
            ConfigElement.getPath(GraphDatabaseConfiguration.JOB_START_TIME),
            String.valueOf(System.currentTimeMillis()));
}
 
Example 20
Project: titan1withtp3.1   File: MapReduceIndexJobs.java   View source code 5 votes vote down vote up
private static void copyPropertiesToInputAndOutputConf(Configuration sink, Properties source) {
    final String prefix = ConfigElement.getPath(TitanHadoopConfiguration.GRAPH_CONFIG_KEYS, true) + ".";
    for (Map.Entry<Object, Object> e : source.entrySet()) {
        String k;
        String v = e.getValue().toString();
        k = prefix + e.getKey().toString();
        sink.set(k, v);
        log.info("Set {}={}", k, v);
    }
}
 
Example 21
Project: titan1withtp3.1   File: ConfigurationPrinter.java   View source code 5 votes vote down vote up
private List<ConfigOption<?>> getSortedChildOptions(ConfigNamespace n) {
    return getSortedChildren(n, new Function<ConfigElement, Boolean>() {
        @Override
        public Boolean apply(ConfigElement arg0) {
            return arg0.isOption() && !((ConfigOption)arg0).isHidden();
        }
    });
}
 
Example 22
Project: titan1withtp3.1   File: ConfigurationPrinter.java   View source code 5 votes vote down vote up
private List<ConfigNamespace> getSortedChildNamespaces(ConfigNamespace n) {
    return getSortedChildren(n, new Function<ConfigElement, Boolean>() {
        @Override
        public Boolean apply(ConfigElement arg0) {
            return arg0.isNamespace();
        }
    });
}
 
Example 23
Project: titan1.0.1.kafka   File: AbstractTitanGraphProvider.java   View source code 5 votes vote down vote up
@Override
public Map<String, Object> getBaseConfiguration(String graphName, Class<?> test, String testMethodName, final LoadGraphWith.GraphData loadGraphWith) {
    ModifiableConfiguration conf = getTitanConfiguration(graphName, test, testMethodName);
    conf.set(GraphDatabaseConfiguration.COMPUTER_RESULT_MODE, "persist");
    conf.set(GraphDatabaseConfiguration.AUTO_TYPE, "tp3");
    Map<String, Object> result = new HashMap<>();
    conf.getAll().entrySet().stream().forEach(e -> result.put(ConfigElement.getPath(e.getKey().element, e.getKey().umbrellaElements), e.getValue()));
    result.put(Graph.GRAPH, TitanFactory.class.getName());
    return result;
}
 
Example 24
Project: titan1.0.1.kafka   File: BerkeleyGraphTest.java   View source code 5 votes vote down vote up
@Override
public void testConsistencyEnforcement() {
    // Check that getConfiguration() explicitly set serializable isolation
    // This could be enforced with a JUnit assertion instead of a Precondition,
    // but a failure here indicates a problem in the test itself rather than the
    // system-under-test, so a Precondition seems more appropriate
    IsolationLevel effective = ConfigOption.getEnumValue(config.get(ConfigElement.getPath(BerkeleyJEStoreManager.ISOLATION_LEVEL), String.class),IsolationLevel.class);
    Preconditions.checkState(IsolationLevel.SERIALIZABLE.equals(effective));
    super.testConsistencyEnforcement();
}
 
Example 25
Project: titan1.0.1.kafka   File: MapReduceIndexManagement.java   View source code 5 votes vote down vote up
private static void copyIndexJobKeys(org.apache.hadoop.conf.Configuration hadoopConf, String indexName, String relationType) {
    hadoopConf.set(ConfigElement.getPath(TitanHadoopConfiguration.SCAN_JOB_CONFIG_KEYS, true) + "." +
                    ConfigElement.getPath(IndexUpdateJob.INDEX_NAME), indexName);

    hadoopConf.set(ConfigElement.getPath(TitanHadoopConfiguration.SCAN_JOB_CONFIG_KEYS, true) + "." +
            ConfigElement.getPath(IndexUpdateJob.INDEX_RELATION_TYPE), relationType);

    hadoopConf.set(ConfigElement.getPath(TitanHadoopConfiguration.SCAN_JOB_CONFIG_KEYS, true) + "." +
            ConfigElement.getPath(GraphDatabaseConfiguration.JOB_START_TIME),
            String.valueOf(System.currentTimeMillis()));
}
 
Example 26
Project: titan1.0.1.kafka   File: MapReduceIndexJobs.java   View source code 5 votes vote down vote up
private static void copyPropertiesToInputAndOutputConf(Configuration sink, Properties source) {
    final String prefix = ConfigElement.getPath(TitanHadoopConfiguration.GRAPH_CONFIG_KEYS, true) + ".";
    for (Map.Entry<Object, Object> e : source.entrySet()) {
        String k;
        String v = e.getValue().toString();
        k = prefix + e.getKey().toString();
        sink.set(k, v);
        log.info("Set {}={}", k, v);
    }
}
 
Example 27
Project: titan1.0.1.kafka   File: ConfigurationPrinter.java   View source code 5 votes vote down vote up
private List<ConfigOption<?>> getSortedChildOptions(ConfigNamespace n) {
    return getSortedChildren(n, new Function<ConfigElement, Boolean>() {
        @Override
        public Boolean apply(ConfigElement arg0) {
            return arg0.isOption() && !((ConfigOption)arg0).isHidden();
        }
    });
}
 
Example 28
Project: titan1.0.1.kafka   File: ConfigurationPrinter.java   View source code 5 votes vote down vote up
private List<ConfigNamespace> getSortedChildNamespaces(ConfigNamespace n) {
    return getSortedChildren(n, new Function<ConfigElement, Boolean>() {
        @Override
        public Boolean apply(ConfigElement arg0) {
            return arg0.isNamespace();
        }
    });
}
 
Example 29
Project: titan0.5.4-hbase1.1.1-custom   File: BerkeleyGraphTest.java   View source code 5 votes vote down vote up
@Override
public void testConsistencyEnforcement() {
    // Check that getConfiguration() explicitly set serializable isolation
    // This could be enforced with a JUnit assertion instead of a Precondition,
    // but a failure here indicates a problem in the test itself rather than the
    // system-under-test, so a Precondition seems more appropriate
    IsolationLevel effective = config.get(ConfigElement.getPath(BerkeleyJEStoreManager.ISOLATION_LEVEL), IsolationLevel.class);
    Preconditions.checkState(IsolationLevel.SERIALIZABLE.equals(effective));
    super.testConsistencyEnforcement();
}
 
Example 30
Project: titan0.5.4-hbase1.1.1-custom   File: RDFBlueprintsHandler.java   View source code 5 votes vote down vote up
public RDFBlueprintsHandler(final ModifiableHadoopConfiguration configuration) throws IOException {


        // exclude fragments which are most likely to interfere in a Titan/Faunus pipeline
        reservedFragments = new HashSet<String>();
        reservedFragments.add("label");
        //reservedFragments.add("type");
        reservedFragments.add("id");

        faunusConf = configuration;
        rdfConf = faunusConf.getInputConf(ROOT_NS);

        this.baseURI = rdfConf.get(RDF_BASE_URI);
        this.useFragments = rdfConf.get(RDF_USE_LOCALNAME);
        this.literalAsProperty = rdfConf.get(RDF_LITERAL_AS_PROPERTY);
        for (final String property : rdfConf.get(RDF_AS_PROPERTIES)) {
            this.asProperties.add(property.trim());
        }

        if (!rdfConf.has(RDF_FORMAT)) {
            throw new RuntimeException("RDF format is required.  Set " + ConfigElement.getPath(TitanHadoopConfiguration.INPUT_CONF_NS) + "." + RDF_FORMAT.getName());
        }
        Syntax syntax = rdfConf.get(RDF_FORMAT);
        RDFFormat format = syntax.getRDFFormat();
        Preconditions.checkNotNull(format);

        this.parser = Rio.createParser(format);

        this.parser.setRDFHandler(this);
        this.parser.setDatatypeHandling(RDFParser.DatatypeHandling.IGNORE);
    }
 
Example 31
Project: titan0.5.4-hbase1.1.1-custom   File: TitanIndexRepair.java   View source code 5 votes vote down vote up
private static void copyPropertiesToInputAndOutputConf(Configuration sink, Properties source) {
    for (Map.Entry<Object, Object> e : source.entrySet()) {
        String k;
        String v = e.getValue().toString();
        k = ConfigElement.getPath(TitanHadoopConfiguration.INPUT_CONF_NS) + "." + e.getKey().toString();
        sink.set(k, v);
        log.info("Set {}={}", k, v);
        k = ConfigElement.getPath(TitanHadoopConfiguration.OUTPUT_CONF_NS) + "." + e.getKey().toString();
        sink.set(k, v);
        log.info("Set {}={}", k, v);
    }
}
 
Example 32
Project: titan0.5.4-hbase1.1.1-custom   File: ModifiableHadoopConfiguration.java   View source code 5 votes vote down vote up
public void setAllOutput(Map<ConfigElement.PathIdentifier, Object> entries) {
    ModifiableConfiguration out = getOutputConf();
    for (Map.Entry<ConfigElement.PathIdentifier,Object> entry : entries.entrySet()) {
        Preconditions.checkArgument(entry.getKey().element.isOption());
        out.set((ConfigOption) entry.getKey().element, entry.getValue(), entry.getKey().umbrellaElements);
    }
}
 
Example 33
Project: titan0.5.4-hbase1.1.1-custom   File: ModifiableHadoopConfiguration.java   View source code 5 votes vote down vote up
public void setAllInput(Map<ConfigElement.PathIdentifier, Object> entries) {
    ModifiableConfiguration in = getInputConf();
    for (Map.Entry<ConfigElement.PathIdentifier,Object> entry : entries.entrySet()) {
        Preconditions.checkArgument(entry.getKey().element.isOption());
        in.set((ConfigOption) entry.getKey().element, entry.getValue(), entry.getKey().umbrellaElements);
    }
}
 
Example 34
Project: titan0.5.4-hbase1.1.1-custom   File: ConfigurationPrinter.java   View source code 5 votes vote down vote up
private List<ConfigOption<?>> getSortedChildOptions(ConfigNamespace n) {
    return getSortedChildren(n, new Function<ConfigElement, Boolean>() {
        @Override
        public Boolean apply(ConfigElement arg0) {
            return arg0.isOption() && !((ConfigOption)arg0).isHidden();
        }
    });
}
 
Example 35
Project: titan0.5.4-hbase1.1.1-custom   File: ConfigurationPrinter.java   View source code 5 votes vote down vote up
private List<ConfigNamespace> getSortedChildNamespaces(ConfigNamespace n) {
    return getSortedChildren(n, new Function<ConfigElement, Boolean>() {
        @Override
        public Boolean apply(ConfigElement arg0) {
            return arg0.isNamespace();
        }
    });
}
 
Example 36
Project: titan1withtp3.1   File: TitanGraphTest.java   View source code 4 votes vote down vote up
private <T> void setAndCheckGraphOption(ConfigOption<T> opt, ConfigOption.Type requiredType, T firstValue, T secondValue) {
    // Sanity check: make sure the Type of the configoption is what we expect
    Preconditions.checkState(opt.getType().equals(requiredType));
    final EnumSet<ConfigOption.Type> allowedTypes =
            EnumSet.of(ConfigOption.Type.GLOBAL,
                    ConfigOption.Type.GLOBAL_OFFLINE,
                    ConfigOption.Type.MASKABLE);
    Preconditions.checkState(allowedTypes.contains(opt.getType()));

    // Sanity check: it's kind of pointless for the first and second values to be identical
    Preconditions.checkArgument(!firstValue.equals(secondValue));

    // Get full string path of config option
    final String path = ConfigElement.getPath(opt);

    // Set and check initial value before and after database restart
    mgmt.set(path, firstValue);
    assertEquals(firstValue.toString(), mgmt.get(path));
    // Close open tx first.  This is specific to BDB + GLOBAL_OFFLINE.
    // Basically: the BDB store manager throws a fit if shutdown is called
    // with one or more transactions still open, and GLOBAL_OFFLINE calls
    // shutdown on our behalf when we commit this change.
    tx.rollback();
    mgmt.commit();
    clopen();
    // Close tx again following clopen
    tx.rollback();
    assertEquals(firstValue.toString(), mgmt.get(path));

    // Set and check updated value before and after database restart
    mgmt.set(path, secondValue);
    assertEquals(secondValue.toString(), mgmt.get(path));
    mgmt.commit();
    clopen();
    tx.rollback();
    assertEquals(secondValue.toString(), mgmt.get(path));

    // Open a separate graph "g2"
    TitanGraph g2 = TitanFactory.open(config);
    TitanManagement m2 = g2.openManagement();
    assertEquals(secondValue.toString(), m2.get(path));

    // GLOBAL_OFFLINE options should be unmodifiable with g2 open
    if (opt.getType().equals(ConfigOption.Type.GLOBAL_OFFLINE)) {
        try {
            mgmt.set(path, firstValue);
            mgmt.commit();
            fail("Option " + path + " with type " + ConfigOption.Type.GLOBAL_OFFLINE + " should not be modifiable with concurrent instances");
        } catch (RuntimeException e) {
            log.debug("Caught expected exception", e);
        }
        assertEquals(secondValue.toString(), mgmt.get(path));
        // GLOBAL and MASKABLE should be modifiable even with g2 open
    } else {
        mgmt.set(path, firstValue);
        assertEquals(firstValue.toString(), mgmt.get(path));
        mgmt.commit();
        clopen();
        assertEquals(firstValue.toString(), mgmt.get(path));
    }

    m2.rollback();
    g2.close();
}
 
Example 37
Project: titan1withtp3.1   File: GraphDatabaseConfigurationTest.java   View source code 4 votes vote down vote up
@Test
public void testUniqueNames() {
    assertFalse(StringUtils.containsAny(GraphDatabaseConfiguration.getOrGenerateUniqueInstanceId(Configuration.EMPTY), ConfigElement.ILLEGAL_CHARS));
}
 
Example 38
Project: titan1withtp3.1   File: ModifiableHadoopConfiguration.java   View source code 4 votes vote down vote up
public static ModifiableConfiguration prefixView(ConfigNamespace newRoot, ConfigNamespace prefixRoot,
                                                 ModifiableHadoopConfiguration mc) {
    HadoopConfiguration prefixConf = new HadoopConfiguration(mc.getHadoopConfiguration(),
            ConfigElement.getPath(prefixRoot, true) + ".");
    return new ModifiableConfiguration(newRoot, prefixConf,  Restriction.NONE);
}
 
Example 39
Project: titan1withtp3.1   File: ConsistentKeyLocker.java   View source code 4 votes vote down vote up
@Override
protected void checkSingleLock(final KeyColumn kc, final ConsistentKeyLockStatus ls, final StoreTransaction tx) throws BackendException, InterruptedException {

    if (ls.isChecked())
        return;

    // Sleep, if necessary
    // We could be smarter about sleeping by iterating oldest -> latest...
    final Instant now = times.sleepPast(ls.getWriteTimestamp().plus(lockWait));

    // Slice the store
    KeySliceQuery ksq = new KeySliceQuery(serializer.toLockKey(kc.getKey(), kc.getColumn()), LOCK_COL_START, LOCK_COL_END);
    List<Entry> claimEntries = getSliceWithRetries(ksq, tx);

    // Extract timestamp and rid from the column in each returned Entry...
    Iterable<TimestampRid> iter = Iterables.transform(claimEntries, new Function<Entry, TimestampRid>() {
        @Override
        public TimestampRid apply(Entry e) {
            return serializer.fromLockColumn(e.getColumnAs(StaticBuffer.STATIC_FACTORY), times);
        }
    });
    // ...and then filter out the TimestampRid objects with expired timestamps
    // (This doesn't use Iterables.filter and Predicate so that we can throw a checked exception if necessary)
    ArrayList<TimestampRid> unexpiredTRs = new ArrayList<TimestampRid>(Iterables.size(iter));
    for (TimestampRid tr : iter) {
        final Instant cutoffTime = now.minus(lockExpire);
        if (tr.getTimestamp().isBefore(cutoffTime)) {
            log.warn("Discarded expired claim on {} with timestamp {}", kc, tr.getTimestamp());
            if (null != cleanerService)
                cleanerService.clean(kc, cutoffTime, tx);
            // Locks that this instance wrote that have now expired should not only log but also throw a descriptive exception
            if (rid.equals(tr.getRid()) && ls.getWriteTimestamp().equals(tr.getTimestamp())) {
                throw new ExpiredLockException("Expired lock on " + kc.toString() +
                        ": lock timestamp " + tr.getTimestamp() + " " + times.getUnit() + " is older than " +
                        ConfigElement.getPath(GraphDatabaseConfiguration.LOCK_EXPIRE) + "=" + lockExpire);
                // Really shouldn't refer to GDC.LOCK_EXPIRE here, but this will typically be accurate in a real use case
            }
            continue;
        }
        unexpiredTRs.add(tr);
    }

    checkSeniority(kc, ls, unexpiredTRs);
    ls.setChecked();
}
 
Example 40
Project: titan1withtp3.1   File: HBaseStoreManager.java   View source code 4 votes vote down vote up
private void checkConfigDeprecation(com.thinkaurelius.titan.diskstorage.configuration.Configuration config) {
    if (config.has(GraphDatabaseConfiguration.STORAGE_PORT)) {
        logger.warn("The configuration property {} is ignored for HBase. Set hbase.zookeeper.property.clientPort in hbase-site.xml or {}.hbase.zookeeper.property.clientPort in Titan's configuration file.",
                ConfigElement.getPath(GraphDatabaseConfiguration.STORAGE_PORT), ConfigElement.getPath(HBASE_CONFIGURATION_NAMESPACE));
    }
}