Examples of GraphConfigurationException


Examples of com.tinkerpop.rexster.config.GraphConfigurationException

    public Graph configureGraphInstance(final GraphConfigurationContext context) throws GraphConfigurationException {

        final String graphFile = context.getProperties().getString(Tokens.REXSTER_GRAPH_LOCATION);

        if (graphFile == null || graphFile.length() == 0) {
            throw new GraphConfigurationException("Check graph configuration. Missing or empty configuration element: " + Tokens.REXSTER_GRAPH_LOCATION);
        }

        final boolean highAvailabilityMode = context.getProperties().getBoolean(Tokens.REXSTER_GRAPH_HA, false);

        // get the <properties> section of the xml configuration
        final HierarchicalConfiguration graphSectionConfig = (HierarchicalConfiguration) context.getProperties();
        SubnodeConfiguration neo4jSpecificConfiguration;

        try {
            neo4jSpecificConfiguration = graphSectionConfig.configurationAt(Tokens.REXSTER_GRAPH_PROPERTIES);
        } catch (IllegalArgumentException iae) {
            throw new GraphConfigurationException("Check graph configuration. Missing or empty configuration element: " + Tokens.REXSTER_GRAPH_PROPERTIES);
        }

        try {

            // properties to initialize the neo4j instance.
            final HashMap<String, String> neo4jProperties = new HashMap<String, String>();

            // read the properties from the xml file and convert them to properties
            // to be injected into neo4j.
            final Iterator<String> neo4jSpecificConfigurationKeys = neo4jSpecificConfiguration.getKeys();
            while (neo4jSpecificConfigurationKeys.hasNext()) {
                String key = neo4jSpecificConfigurationKeys.next();

                // replace the ".." put in play by apache commons configuration.  that's expected behavior
                // due to parsing key names to xml.
                neo4jProperties.put(key.replace("..", "."), neo4jSpecificConfiguration.getString(key));
            }

            if (highAvailabilityMode) {
                if (!neo4jProperties.containsKey("ha.machine_id")) {
                    throw new GraphConfigurationException("Check graph configuration. Neo4j HA requires [ha.machine_id] in the <properties> of the configuration");
                }

                if (!neo4jProperties.containsKey("ha.server")) {
                    throw new GraphConfigurationException("Check graph configuration. Neo4j HA requires [ha.server] <properties> of the configuration");
                }

                if (!neo4jProperties.containsKey("ha.initial_hosts")) {
                    throw new GraphConfigurationException("Check graph configuration. Neo4j HA requires [ha.initial_hosts] <properties> of the configuration");
                }

                return new Neo4j2HaGraph(graphFile, neo4jProperties);

            } else {
                return new Neo4j2Graph(graphFile, neo4jProperties);
            }

        } catch (GraphConfigurationException gce) {
            throw gce;
        } catch (Exception ex) {
            throw new GraphConfigurationException(ex);
        }
    }
View Full Code Here

Examples of com.tinkerpop.rexster.config.GraphConfigurationException

  public Graph configureGraphInstance(final GraphConfigurationContext context) throws GraphConfigurationException {

    final String graphFile = context.getProperties().getString(Tokens.REXSTER_GRAPH_LOCATION);

    if (graphFile == null || graphFile.length() == 0) {
      throw new GraphConfigurationException("Check graph configuration. Missing or empty configuration element: "
          + Tokens.REXSTER_GRAPH_LOCATION);
    }

    // get the <properties> section of the xml configuration
    final HierarchicalConfiguration graphSectionConfig = (HierarchicalConfiguration) context.getProperties();
    SubnodeConfiguration orientDbSpecificConfiguration;

    try {
      orientDbSpecificConfiguration = graphSectionConfig.configurationAt(Tokens.REXSTER_GRAPH_PROPERTIES);
    } catch (IllegalArgumentException iae) {
      throw new GraphConfigurationException("Check graph configuration. Missing or empty configuration element: "
          + Tokens.REXSTER_GRAPH_PROPERTIES);
    }

    try {

      final String username = orientDbSpecificConfiguration.getString("username", "");
      final String password = orientDbSpecificConfiguration.getString("password", "");

      // Caching must be turned off. OrientDB has different layers of cache:
      // http://code.google.com/p/orient/wiki/Caching There's one Level1 cache per OGraphDatabase instance
      // and one level2 per JVM. If a OGraphDatabase caches a vertex and then you change it in
      // another thread/transaction you could see the older one. To fix it just disable the Level1 cache.
      // If there were multiple running JVM you could have Level2 cache not updated for the same reason as
      // above. Then you've to disable Level2 cache....per Luca.
      //
      // Disabling the level 1 cache seems to solve the problem where POSTs of edges in rapid succession
      // force a transaction error like: Cannot update record #6:0 in storage 'orientdb-graph' because the
      // version is not the latest. Probably you are updating an old record or it has been modified by
      // another user (db=v2 your=v0)
      OGlobalConfiguration.CACHE_LOCAL_ENABLED.setValue(false);

      // calling the open method opens the connection to graphdb. looks like the
      // implementation of shutdown will call the orientdb close method.
      return new OrientGraph(graphFile, username, password);

    } catch (Exception ex) {
      throw new GraphConfigurationException(ex);
    }
  }
View Full Code Here

Examples of com.tinkerpop.rexster.config.GraphConfigurationException

    /** {@inheritDoc} */
    @Override
    public Graph configureGraphInstance(final Configuration properties) throws GraphConfigurationException {
        final String location = properties.getString(Tokens.REXSTER_GRAPH_LOCATION);
        if (StringUtils.isBlank(location)) {
            throw new GraphConfigurationException("issing or empty configuration element: "
                    + Tokens.REXSTER_GRAPH_LOCATION);
        }
        // Classloading issue: No suitable driver found
        Thread.currentThread().setContextClassLoader(Driver.class.getClassLoader());
        return new FluxGraph(location);
View Full Code Here

Examples of com.tinkerpop.rexster.config.GraphConfigurationException

        SubnodeConfiguration orientDbSpecificConfiguration;

        try {
            orientDbSpecificConfiguration = graphSectionConfig.configurationAt(Tokens.REXSTER_GRAPH_PROPERTIES);
        } catch (IllegalArgumentException iae) {
            throw new GraphConfigurationException("Check graph configuration. Missing or empty configuration element: " + Tokens.REXSTER_GRAPH_PROPERTIES);
        }

        final String username = orientDbSpecificConfiguration.getString("username", null);
        final String password = orientDbSpecificConfiguration.getString("password", null);
        final String host = orientDbSpecificConfiguration.getString("host", "localhost");
        final int port = orientDbSpecificConfiguration.getInt("port", 27017);

        if(username != null && password != null) {
            // create mongo graph with username and password
            try {
                return new MongoDBGraph(host, port, username, password);
            } catch (Exception ex) {
                throw new GraphConfigurationException(ex);
            }
        } else {
            try {
                return new MongoDBGraph(host, port);

            } catch (Exception ex) {
                throw new GraphConfigurationException(ex);
            }  
        }
       
    }
View Full Code Here

Examples of com.tinkerpop.rexster.config.GraphConfigurationException

                    String listVal = Joiner.on(AbstractConfiguration.getDefaultListDelimiter()).join(titanConfigProperties.getStringArray(doubleDotKey));
                   
                    titanConfig.setProperty(singleDotKey, listVal);
                }
            } catch (IllegalArgumentException iae) {
                throw new GraphConfigurationException("Check graph configuration. Missing or empty configuration element: " + Tokens.REXSTER_GRAPH_PROPERTIES);
            }

            final Configuration rewriteConfig = new BaseConfiguration();
            final String location = properties.getString(Tokens.REXSTER_GRAPH_LOCATION, "");
            if (titanConfig.getString("storage.backend").equals("local") && location.trim().length() > 0) {
                final File directory = new File(properties.getString(Tokens.REXSTER_GRAPH_LOCATION));
                if (!directory.isDirectory()) {
                    if (!directory.mkdirs()) {
                        throw new IllegalArgumentException("Could not create directory: " + directory);
                    }
                }
                rewriteConfig.setProperty("storage.directory", directory.toString());
            }

            if (properties.containsKey(Tokens.REXSTER_GRAPH_READ_ONLY)) {
                rewriteConfig.setProperty("storage.read-only", properties.getBoolean(Tokens.REXSTER_GRAPH_READ_ONLY));
            }

            final CompositeConfiguration jointConfig = new CompositeConfiguration();
            jointConfig.addConfiguration(rewriteConfig);
            jointConfig.addConfiguration(titanConfig);
            return jointConfig;
        } catch (Exception e) {
            //Unroll exceptions so that Rexster prints root cause
            Throwable cause = e;
            while (cause.getCause() != null) {
                cause = cause.getCause();
            }
            throw new GraphConfigurationException(cause);
        }
    }
View Full Code Here

Examples of com.tinkerpop.rexster.config.GraphConfigurationException

        SubnodeConfiguration kvSpecificConfiguration;

        try {
            kvSpecificConfiguration = graphSectionConfig.configurationAt(Tokens.REXSTER_GRAPH_PROPERTIES);
        } catch (IllegalArgumentException iae) {
            throw new GraphConfigurationException("Check graph configuration. Missing or empty configuration element: " + Tokens.REXSTER_GRAPH_PROPERTIES);
        }

        try {

            final String host = kvSpecificConfiguration.getString("host");
            final int port = kvSpecificConfiguration.getInt("port", 5000);
            final String storeName = kvSpecificConfiguration.getString("store-name");
            final String graphName = configuration.getString("graph-name");

            return new KVGraph(graphName, storeName, host, port);

        } catch (Exception ex) {
            throw new GraphConfigurationException(ex);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.