@Override public void updateConfiguration(final Configuration config, final int hint) { /** Can be extended. */ if (config == null) { return; } if (ConfigHint.NATIVE_FILE == hint || ConfigHint.CLI_OVERRIDE == hint) { setIdeaSleepNano(config.getLong(PollingKey.idleSleepNano.name(), idleSleepNano)); } }
public void buildNetwork() throws ConfigurationException { // build transport Configuration transportConfigs = _config.subset(TRANSPORT_CONFIG_PREFIX); TransportClientConf conf = new TransportClientConf(); conf.init(transportConfigs); _registry = new MetricsRegistry(); MetricsHelper.initializeMetrics(_config.subset(METRICS_CONFIG_PREFIX)); MetricsHelper.registerMetricsRegistry(_registry); _brokerMetrics = new BrokerMetrics(_registry); _brokerMetrics.initializeGlobalMeters(); _state.set(State.INIT); _eventLoopGroup = new NioEventLoopGroup(); /** * Some of the client metrics uses histogram which is doing synchronous operation. These are * fixed overhead per request/response. TODO: Measure the overhead of this. */ final NettyClientMetrics clientMetrics = new NettyClientMetrics(_registry, "client_"); // Setup Netty Connection Pool _resourceManager = new PooledNettyClientResourceManager( _eventLoopGroup, new HashedWheelTimer(), clientMetrics); _poolTimeoutExecutor = new ScheduledThreadPoolExecutor(50); // _requestSenderPool = MoreExecutors.sameThreadExecutor(); final ConnectionPoolConfig cfg = conf.getConnPool(); _requestSenderPool = Executors.newCachedThreadPool(); ConnectionPoolConfig connPoolCfg = conf.getConnPool(); _connPool = new KeyedPoolImpl<ServerInstance, NettyClientConnection>( connPoolCfg.getMinConnectionsPerServer(), connPoolCfg.getMaxConnectionsPerServer(), connPoolCfg.getIdleTimeoutMs(), connPoolCfg.getMaxBacklogPerServer(), _resourceManager, _poolTimeoutExecutor, _requestSenderPool, _registry); // MoreExecutors.sameThreadExecutor(), _registry); _resourceManager.setPool(_connPool); // Setup Routing Table if (conf.getRoutingMode() == RoutingMode.CONFIG) { final CfgBasedRouting rt = new CfgBasedRouting(); rt.init(conf.getCfgBasedRouting()); _routingTable = rt; } else { // Helix based routing is already initialized. } // Setup ScatterGather _scatterGather = new ScatterGatherImpl(_connPool, _requestSenderPool); // Setup Broker Request Handler long brokerTimeOut = DEFAULT_BROKER_TIME_OUT; if (_config.containsKey(BROKER_TIME_OUT_CONFIG)) { try { brokerTimeOut = _config.getLong(BROKER_TIME_OUT_CONFIG); } catch (Exception e) { LOGGER.warn( "Caught exception while reading broker timeout from config, using default value", e); } } LOGGER.info("Broker timeout is - " + brokerTimeOut + " ms"); _requestHandler = new BrokerRequestHandler( _routingTable, _timeBoundaryService, _scatterGather, new DefaultReduceService(), _brokerMetrics, brokerTimeOut); // TODO: Start Broker Server : Code goes here. Broker Server part should use request handler to // submit requests LOGGER.info("Network initialized !!"); }
/** * @param aArgs * @return */ public JWSEndPoint start(String[] aArgs) { // set up log4j logging // later this should be read from a shared log4j properties or xml file! Properties lProps = new Properties(); lProps.setProperty("log4j.rootLogger", "INFO, console"); lProps.setProperty("log4j.logger.org.apache.activemq", "WARN"); lProps.setProperty("log4j.logger.org.springframework", "WARN"); lProps.setProperty("log4j.logger.org.apache.xbean", "WARN"); lProps.setProperty("log4j.logger.org.apache.camel", "INFO"); lProps.setProperty("log4j.logger.org.eclipse.jetty", "WARN"); lProps.setProperty("log4j.appender.console", "org.apache.log4j.ConsoleAppender"); lProps.setProperty("log4j.appender.console.layout", "org.apache.log4j.PatternLayout"); lProps.setProperty( "log4j.appender.console.layout.ConversionPattern", // "%p: %m%n" "%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p - %C{1}: %m%n"); // set here the jWebSocket log level: lProps.setProperty("log4j.logger.org.jwebsocket", "DEBUG"); lProps.setProperty("log4j.appender.console.threshold", "DEBUG"); PropertyConfigurator.configure(lProps); final JWSAutoSelectAuthenticator lAuthenticator = new JWSAutoSelectAuthenticator(); final JWSOAuthAuthenticator lOAuthAuthenticator = new JWSOAuthAuthenticator(); final JWSLDAPAuthenticator lLDAPAuthenticator = new JWSLDAPAuthenticator(); mLog.info("jWebSocket JMS Gateway Server Endpoint"); Configuration lConfig = null; boolean lConfigLoaded; try { // try to load properties files from local folder or jar String lPath = "JMSServer.properties"; mLog.debug("Trying to read properties from: " + lPath); lConfig = new PropertiesConfiguration(lPath); } catch (ConfigurationException ex) { } if (null == lConfig) { try { // try to load properties files from JWEBSOCKET_HOME/conf/JMSPlugIn String lPath = Tools.expandEnvVarsAndProps("/private/JMSServer.properties"); // String lPath = // Tools.expandEnvVarsAndProps("${JWEBSOCKET_HOME}conf/JMSPlugIn/JMSServer.properties"); mLog.debug("Tring to read properties from: " + lPath); lConfig = new PropertiesConfiguration(lPath); } catch (ConfigurationException ex) { } } if (null == lConfig) { mLog.error("Configuration file could not be opened."); return null; } // the URL of the message broker String lBrokerURL = lConfig.getString("BrokerURL", "tcp://127.0.0.1:61616"); // "failover:(tcp://0.0.0.0:61616,tcp://127.0.0.1:61616)?initialReconnectDelay=100&randomize=false"; // the name of the JMS Gateway topic String lGatewayTopic = lConfig.getString("GatewayTopic", "org.jwebsocket.jms.gateway"); // endpoint id of JMS Gateway String lGatewayId = lConfig.getString("GatewayId", "org.jwebsocket.jms.gateway"); String lEndPointId = lConfig.getString("EndPointId", UUID.randomUUID().toString()); // get authentication information against jWebSocket final String lJWSUsername = lConfig.getString("JWSUsername"); final String lJWSPassword = lConfig.getString("JWSPassword"); final boolean lFullTextLogging = lConfig.getBoolean("FullTextLogging", false); // set up OAuth Authenticator boolean lUseOAuth = lConfig.getBoolean("UseOAuth", false); String lOAuthHost = lConfig.getString("OAuthHost"); String lOAuthAppId = lConfig.getString("OAuthAppId"); String lOAuthAppSecret = lConfig.getString("OAuthAppSecret"); String lOAuthUsername = lConfig.getString("OAuthUsername"); String lOAuthPassword = lConfig.getString("OAuthPassword"); long lOAuthTimeout = lConfig.getLong("OAuthTimeout", 5000); lUseOAuth = lUseOAuth && null != lOAuthHost && null != lOAuthAppId && null != lOAuthAppSecret && null != lOAuthUsername && null != lOAuthPassword; if (lUseOAuth) { lOAuthAuthenticator.init(lOAuthHost, lOAuthAppId, lOAuthAppSecret, lOAuthTimeout); lAuthenticator.addAuthenticator(lOAuthAuthenticator); } // set up LDAP Authenticator boolean lUseLDAP = lConfig.getBoolean("UseLDAP", false); String lLDAPURL = lConfig.getString("LDAPURL"); String lBaseDNGroups = lConfig.getString("BaseDNGroups"); String lBaseDNUsers = lConfig.getString("BaseDNUsers"); if (lUseLDAP) { lLDAPAuthenticator.init(lLDAPURL, lBaseDNGroups, lBaseDNUsers); lAuthenticator.addAuthenticator(lLDAPAuthenticator); } // TODO: Validate config data here! lConfigLoaded = true; if (!lConfigLoaded) { mLog.error("Config not loaded."); System.exit(1); } mLog.info( "Using: " + lBrokerURL + ", " + "topic: " + lGatewayTopic + ", " + "gateway-id: " + lGatewayId + ", " + "endpoint-id: " + lEndPointId); // todo: Comment that for production purposes JMSLogging.setFullTextLogging(lFullTextLogging); // instantiate a new jWebSocket JMS Gateway Client try { lJWSEndPoint = JWSEndPoint.getInstance( lBrokerURL, lGatewayTopic, // gateway topic lGatewayId, // gateway endpoint id lEndPointId, // unique node id 5, // thread pool size, messages being processed concurrently JMSEndPoint.TEMPORARY // durable (for servers) or temporary (for clients) ); } catch (JMSException lEx) { mLog.fatal("JMSEndpoint could not be instantiated: " + lEx.getMessage()); System.exit(0); } lJWSEndPoint.addRequestListener( "org.jwebsocket.jms.gateway", "welcome", new JWSMessageListener(lJWSEndPoint) { @Override public void processToken(String aSourceId, Token aToken) { mLog.info("Received 'welcome', authenticating against jWebSocket..."); Token lToken = TokenFactory.createToken("org.jwebsocket.plugins.system", "login"); lToken.setString("username", lJWSUsername); lToken.setString("password", lJWSPassword); sendToken(aSourceId, lToken); } }); // on response of the login... lJWSEndPoint.addResponseListener( "org.jwebsocket.plugins.system", "login", new JWSMessageListener(lJWSEndPoint) { @Override public void processToken(String aSourceId, Token aToken) { int lCode = aToken.getInteger("code", -1); if (0 == lCode) { if (mLog.isInfoEnabled()) { mLog.info("Authentication against jWebSocket successful."); } } else { mLog.error("Authentication against jWebSocket failed!"); } } }); // on response of the login... lJWSEndPoint.addRequestListener( "org.jwebsocket.jms.demo", "getUser", new JWSMessageListener(lJWSEndPoint) { @Override public void processToken(String aSourceId, Token aToken) { String lPayload = aToken.getString("payload"); if (mLog.isInfoEnabled()) { mLog.info("Processing 'getUser'..."); } } }); // on response of the login... lJWSEndPoint.addRequestListener( "org.jwebsocket.jms.demo", "echo", new JWSMessageListener(lJWSEndPoint) { @Override public void processToken(String aSourceId, Token aToken) { String lPayload = aToken.getString("payload"); if (mLog.isInfoEnabled()) { mLog.info("Processing 'demo1 with Payload '" + lPayload + "'"); } Map<String, Object> lAdditionalResults = new FastMap<String, Object>(); lAdditionalResults.putAll(aToken.getMap()); // lAdditionalResults.remove("sourceId"); lAdditionalResults.remove("payload"); lJWSEndPoint.respondPayload( aToken, 0, // return code "Ok", // return message lAdditionalResults, aToken.getString("payload")); } }); // on response of the login... lJWSEndPoint.addRequestListener( "org.jwebsocket.jms.demo", "testProgress", new JWSMessageListener(lJWSEndPoint) { @Override @SuppressWarnings("SleepWhileInLoop") public void processToken(String aSourceId, Token aToken) { int lMax = 10; for (int lIdx = 0; lIdx < lMax; lIdx++) { mLog.debug("Progress iteration " + lIdx + "..."); try { Thread.sleep(333); } catch (InterruptedException lEx) { } lJWSEndPoint.sendProgress( aToken, ((lIdx + 1.0) / lMax) * 100, 0, "Iteration #" + lIdx, null); } lJWSEndPoint.respondPayload( aToken, 0, // return code "Ok", // return message null, aToken.getString("payload")); } }); // ... lJWSEndPoint.addRequestListener( "org.jwebsocket.jms.demo", "testCaughtException", new JWSMessageListener(lJWSEndPoint) { @Override public void processToken(String aSourceId, Token aToken) { mLog.debug("Testing caught exception..."); // provoke null pointer exception and DO catch it for test purposes int a = 1; int b = 0; try { int c = a / b; lJWSEndPoint.respondPayload( aToken, 0, // return code "Ok", // return message null, aToken.getString("payload")); } catch (Exception Ex) { lJWSEndPoint.respondPayload( aToken, -1, // return code Ex.getClass().getSimpleName() + ": " + Ex.getMessage(), // return message null, aToken.getString("payload")); } } }); // ... lJWSEndPoint.addRequestListener( "org.jwebsocket.jms.demo", "testUncaughtException", new JWSMessageListener(lJWSEndPoint) { @Override public void processToken(String aSourceId, Token aToken) { mLog.debug("Testing uncaught exception..."); // provoke null pointer exception and do NOT catch it for test purposes int a = 1; int b = 0; int c = a / b; lJWSEndPoint.respondPayload( aToken, 0, // return code "Ok", // return message null, aToken.getString("payload")); } }); // test for the OAuth interface lJWSEndPoint.addRequestListener( "org.jwebsocket.jms.demo", "testOAuth", new JWSMessageListener(lJWSEndPoint) { @Override public void processToken(String aSourceId, Token aToken) { Map<String, Object> lArgs = new FastMap<String, Object>(); String lUsername; int lCode = 0; String lMessage = "Ok"; try { lUsername = lOAuthAuthenticator.authToken(aToken); if (null == lUsername) { lCode = -1; lMessage = "User could not be authenticated!"; } else { lArgs.put("username", lUsername); } } catch (JMSEndpointException ex) { lCode = -1; lMessage = ex.getClass().getSimpleName() + " on authentication: " + ex.getMessage(); } lJWSEndPoint.respondPayload( aToken, lCode, // return code lMessage, // return message lArgs, // additional result fields null); // payload } }); // test for the LDAP interface lJWSEndPoint.addRequestListener( "org.jwebsocket.jms.demo", "testLDAP", new JWSMessageListener(lJWSEndPoint) { @Override public void processToken(String aSourceId, Token aToken) { Map<String, Object> lArgs = new FastMap<String, Object>(); String lUsername; int lCode = 0; String lMessage = "Ok"; try { lUsername = lLDAPAuthenticator.authToken(aToken); if (null == lUsername) { lCode = -1; lMessage = "User could not be authenticated!"; } else { lArgs.put("username", lUsername); } } catch (JMSEndpointException ex) { lCode = -1; lMessage = ex.getClass().getSimpleName() + " on authentication: " + ex.getMessage(); } lJWSEndPoint.respondPayload( aToken, lCode, // return code lMessage, // return message lArgs, // additional result fields null); // payload } }); // test for the auto authentication interface lJWSEndPoint.addRequestListener( "org.jwebsocket.jms.demo", "testAuth", new JWSMessageListener(lJWSEndPoint) { @Override public void processToken(String aSourceId, Token aToken) { mLog.debug("Testing auto authenticator..."); Map<String, Object> lArgs = new FastMap<String, Object>(); String lUsername; int lCode = 0; String lMessage = "Ok"; try { checkADUsername(aToken); lUsername = lAuthenticator.authToken(aToken); if (null == lUsername) { lCode = -1; lMessage = "User could not be authenticated!"; } else { lArgs.put("username", lUsername); } } catch (JMSEndpointException lEx) { lCode = -1; lMessage = lEx.getClass().getSimpleName() + " on auto authentication: " + lEx.getMessage(); } lJWSEndPoint.respondPayload( aToken, lCode, // return code lMessage, // return message lArgs, // additional result fields null); // payload } }); lJWSEndPoint.addRequestListener( "tld.yourname.jms", "transferFile", new JWSMessageListener(lJWSEndPoint) { @Override public void processToken(String aSourceId, Token aToken) { // here you can get the additional arguments mLog.info( "Received 'transferFile' with additional args" + " (arg1=" + aToken.getString("arg1") + " (arg2=" + aToken.getString("arg2") + ")..."); // here you get the payload from the requester String lPayload = aToken.getString("payload"); // parse the JSON payload into a Token (for simpler processing) Token lToken = JSONProcessor.JSONStringToToken(lPayload); // extract the base64 and compressed file contents into Strings // (it's a text message) // String lBase64Encoded = lToken.getString("fileAsBase64"); String lBase64Zipped = lToken.getString("fileAsZip"); // specify the target file File lFile = new File("Apache License 2.0 (copy).txt"); try { // take the zipped version of the file... byte[] lBA = Tools.unzip(lBase64Zipped.getBytes("UTF-8"), Boolean.TRUE); // and save it to the hard disk FileUtils.writeByteArrayToFile(lFile, lBA); } catch (Exception lEx) { mLog.error("Demo file " + lFile.getAbsolutePath() + " could not be saved!"); } } }); // add a high level listener to listen in coming messages lJWSEndPoint.addRequestListener( "org.jwebsocket.jms.demo", "helloWorld", new JWSMessageListener(lJWSEndPoint) { @Override public void processToken(String aSourceId, Token aToken) { mLog.info("Received 'helloWorld'..."); lJWSEndPoint.respondPayload( aToken.getString("sourceId"), aToken, 0, // return code "Ok", // return message null, // here you can add additional results beside the payload "Hello World!"); } }); // start the endpoint all all listener have been assigned lJWSEndPoint.start(); return lJWSEndPoint; }
public SenseiCore buildCore() throws ConfigurationException { SenseiUncaughtExceptionHandler.setAsDefaultForAllThreads(); int nodeid = _senseiConf.getInt(NODE_ID); String partStr = _senseiConf.getString(PARTITIONS); String[] partitionArray = partStr.split("[,\\s]+"); int[] partitions = buildPartitions(partitionArray); logger.info("partitions to serve: " + Arrays.toString(partitions)); // Analyzer from configuration: Analyzer analyzer = pluginRegistry.getBeanByFullPrefix(SENSEI_INDEX_ANALYZER, Analyzer.class); if (analyzer == null) { analyzer = new StandardAnalyzer(Version.LUCENE_35); } // Similarity from configuration: Similarity similarity = pluginRegistry.getBeanByFullPrefix(SENSEI_INDEX_SIMILARITY, Similarity.class); if (similarity == null) { similarity = new DefaultSimilarity(); } ZoieConfig zoieConfig; if (_gateway != null) { zoieConfig = new ZoieConfig(_gateway.getVersionComparator()); } else { zoieConfig = new ZoieConfig(); } zoieConfig.setAnalyzer(analyzer); zoieConfig.setSimilarity(similarity); zoieConfig.setBatchSize( _senseiConf.getInt(SENSEI_INDEX_BATCH_SIZE, ZoieConfig.DEFAULT_SETTING_BATCHSIZE)); zoieConfig.setBatchDelay( _senseiConf.getLong(SENSEI_INDEX_BATCH_DELAY, ZoieConfig.DEFAULT_SETTING_BATCHDELAY)); zoieConfig.setMaxBatchSize( _senseiConf.getInt(SENSEI_INDEX_BATCH_MAXSIZE, ZoieConfig.DEFAULT_MAX_BATCH_SIZE)); zoieConfig.setRtIndexing( _senseiConf.getBoolean(SENSEI_INDEX_REALTIME, ZoieConfig.DEFAULT_SETTING_REALTIME)); zoieConfig.setSkipBadRecord(_senseiConf.getBoolean(SENSEI_SKIP_BAD_RECORDS, false)); int delay = _senseiConf.getInt(SENSEI_INDEX_FRESHNESS, 10); ReaderCacheFactory readercachefactory; if (delay > 0) { readercachefactory = DefaultReaderCache.FACTORY; zoieConfig.setFreshness(delay * 1000); } else { readercachefactory = SimpleReaderCache.FACTORY; } zoieConfig.setReadercachefactory(readercachefactory); ShardingStrategy strategy = pluginRegistry.getBeanByFullPrefix(SENSEI_SHARDING_STRATEGY, ShardingStrategy.class); if (strategy == null) { strategy = new ShardingStrategy.FieldModShardingStrategy(_senseiSchema.getUidField()); } pluggableSearchEngineManager = new PluggableSearchEngineManager(); pluggableSearchEngineManager.init( _senseiConf.getString(SENSEI_INDEX_DIR), nodeid, _senseiSchema, zoieConfig.getVersionComparator(), pluginRegistry, strategy); List<FacetHandler<?>> facetHandlers = new LinkedList<FacetHandler<?>>(); List<RuntimeFacetHandlerFactory<?, ?>> runtimeFacetHandlerFactories = new LinkedList<RuntimeFacetHandlerFactory<?, ?>>(); SenseiSystemInfo sysInfo = null; try { sysInfo = SenseiFacetHandlerBuilder.buildFacets( _schemaDoc, pluginRegistry, facetHandlers, runtimeFacetHandlerFactories, pluggableSearchEngineManager); } catch (JSONException jse) { throw new ConfigurationException(jse.getMessage(), jse); } if (sysInfo != null) { sysInfo.setSchema(_schemaDoc.toString()); try { List<SenseiSystemInfo.SenseiNodeInfo> clusterInfo = new ArrayList(1); String addr = NetUtil.getHostAddress(); clusterInfo.add( new SenseiSystemInfo.SenseiNodeInfo( nodeid, partitions, String.format("%s:%d", addr, _senseiConf.getInt(SERVER_PORT)), String.format("http://%s:%d", addr, _senseiConf.getInt(SERVER_BROKER_PORT)))); sysInfo.setClusterInfo(clusterInfo); } catch (Exception e) { throw new ConfigurationException(e.getMessage(), e); } } ZoieIndexableInterpreter interpreter = pluginRegistry.getBeanByFullPrefix( SENSEI_INDEX_INTERPRETER, ZoieIndexableInterpreter.class); if (interpreter == null) { DefaultJsonSchemaInterpreter defaultInterpreter = new DefaultJsonSchemaInterpreter(_senseiSchema, pluggableSearchEngineManager); interpreter = defaultInterpreter; CustomIndexingPipeline customIndexingPipeline = pluginRegistry.getBeanByFullPrefix(SENSEI_INDEX_CUSTOM, CustomIndexingPipeline.class); if (customIndexingPipeline != null) { try { defaultInterpreter.setCustomIndexingPipeline(customIndexingPipeline); } catch (Exception e) { logger.error(e.getMessage(), e); } } } SenseiZoieFactory<?> zoieSystemFactory = constructZoieFactory(zoieConfig, facetHandlers, runtimeFacetHandlerFactories, interpreter); SenseiIndexingManager<?> indexingManager = pluginRegistry.getBeanByFullPrefix(SENSEI_INDEX_MANAGER, SenseiIndexingManager.class); if (indexingManager == null) { indexingManager = new DefaultStreamingIndexingManager( _senseiSchema, _senseiConf, pluginRegistry, _gateway, strategy, pluggableSearchEngineManager); } SenseiQueryBuilderFactory queryBuilderFactory = pluginRegistry.getBeanByFullPrefix( SENSEI_QUERY_BUILDER_FACTORY, SenseiQueryBuilderFactory.class); if (queryBuilderFactory == null) { QueryParser queryParser = new QueryParser(Version.LUCENE_35, "contents", analyzer); queryBuilderFactory = new DefaultJsonQueryBuilderFactory(queryParser); } SenseiCore senseiCore = new SenseiCore( nodeid, partitions, zoieSystemFactory, indexingManager, queryBuilderFactory, decorator); senseiCore.setSystemInfo(sysInfo); SenseiIndexPruner indexPruner = pluginRegistry.getBeanByFullPrefix(SENSEI_INDEX_PRUNER, SenseiIndexPruner.class); if (indexPruner != null) { senseiCore.setIndexPruner(indexPruner); } if (pluggableSearchEngineManager != null) { senseiCore.setPluggableSearchEngineManager(pluggableSearchEngineManager); } return senseiCore; }
/** * Initializes this backend with the given configuration. Must be called before this Backend can * be used * * @param config */ public void initialize(Configuration config) { try { // EdgeStore & VertexIndexStore KeyColumnValueStore idStore = getStore(ID_STORE_NAME); if (basicMetrics) { idStore = new MetricInstrumentedStore(idStore, getMetricsStoreName("idStore")); } idAuthority = null; if (storeFeatures.supportsTransactions()) { idAuthority = new TransactionalIDManager(idStore, storeManager, config); } else if (storeFeatures.supportsConsistentKeyOperations()) { idAuthority = new ConsistentKeyIDManager(idStore, storeManager, config); } else { throw new IllegalStateException( "Store needs to support consistent key or transactional operations for ID manager to guarantee proper id allocations"); } edgeStore = getLockStore(getBufferStore(EDGESTORE_NAME)); vertexIndexStore = getLockStore(getBufferStore(VERTEXINDEX_STORE_NAME)); edgeIndexStore = getLockStore(getBufferStore(EDGEINDEX_STORE_NAME), false); if (hashPrefixIndex) { vertexIndexStore = new HashPrefixKeyColumnValueStore(vertexIndexStore, 4); edgeIndexStore = new HashPrefixKeyColumnValueStore(edgeIndexStore, 4); } if (basicMetrics) { edgeStore = new MetricInstrumentedStore(edgeStore, getMetricsStoreName("edgeStore")); vertexIndexStore = new MetricInstrumentedStore(vertexIndexStore, getMetricsStoreName("vertexIndexStore")); edgeIndexStore = new MetricInstrumentedStore(edgeIndexStore, getMetricsStoreName("edgeIndexStore")); } String version = BackendOperation.execute( new Callable<String>() { @Override public String call() throws Exception { String version = storeManager.getConfigurationProperty(TITAN_BACKEND_VERSION); if (version == null) { storeManager.setConfigurationProperty( TITAN_BACKEND_VERSION, TitanConstants.VERSION); version = TitanConstants.VERSION; } return version; } @Override public String toString() { return "ConfigurationRead"; } }, config.getLong(SETUP_WAITTIME_KEY, SETUP_WAITTIME_DEFAULT)); Preconditions.checkState(version != null, "Could not read version from storage backend"); if (!TitanConstants.VERSION.equals(version) && !TitanConstants.COMPATIBLE_VERSIONS.contains(version)) { throw new TitanException( "StorageBackend version is incompatible with current Titan version: " + version + " vs. " + TitanConstants.VERSION); } } catch (StorageException e) { throw new TitanException("Could not initialize backend", e); } }