use of com.alibaba.maxgraph.server.ProcessorLoader in project GraphScope by alibaba.
the class Frontend method initAndStartGremlinServer.
protected void initAndStartGremlinServer() throws Exception {
SchemaFetcher schemaFetcher;
String vineyardSchemaPath = this.instanceConfig.getVineyardSchemaPath();
LOG.info("Read schema from vineyard schema file " + vineyardSchemaPath);
schemaFetcher = new JsonFileSchemaFetcher(vineyardSchemaPath);
this.remoteGraph = new RemoteGraph(this, schemaFetcher);
this.remoteGraph.refresh();
this.graph = new TinkerMaxGraph(instanceConfig, remoteGraph, new DefaultGraphDfs());
this.graphGremlinServer = new MaxGraphServer(this.graph);
int tmpGremlinServerPort = instanceConfig.getGremlinServerPort() > 0 ? instanceConfig.getGremlinServerPort() : 0;
ProcessorLoader processorLoader;
switch(instanceConfig.getGremlinServerMode()) {
case TIMELY:
case MIXED:
{
processorLoader = MixedProcessorLoader.newProcessorLoader(graph, this.instanceConfig, new ExecutorAddressFetcher(clientManager), schemaFetcher, new ZKStatementStore(instanceConfig), new MaxGraphRecordProcessorManager(this.graph, this), this.getFrontendQueryManager());
break;
}
default:
{
processorLoader = GremlinProcessorLoader.newProcessorLoader();
break;
}
}
this.graphGremlinServer.start(tmpGremlinServerPort, processorLoader, instanceConfig.getInstanceAuthType() == 1);
this.gremlinServerPort = tmpGremlinServerPort > 0 ? tmpGremlinServerPort : this.graphGremlinServer.getGremlinServerPort();
LOG.info("gremlin server port:{}", this.gremlinServerPort);
}
use of com.alibaba.maxgraph.server.ProcessorLoader in project GraphScope by alibaba.
the class ReadOnlyGraphServer method start.
@Override
public void start() {
this.loadSettings();
logger.info(GremlinServer.getHeader());
this.settings.port = GremlinConfig.GREMLIN_PORT.get(this.configs);
this.settings.host = "0.0.0.0";
if (settings.gremlinPool == 0) {
settings.gremlinPool = Runtime.getRuntime().availableProcessors();
}
if (StringUtils.equals(settings.channelizer, WsAndHttpChannelizer.class.getName())) {
settings.channelizer = MaxGraphWsAndHttpSocketChannelizer.class.getName();
} else {
throw new IllegalArgumentException("Not support for channelizer=>" + settings.channelizer);
}
settings.writeBufferHighWaterMark = GremlinConfig.SERVER_WRITE_BUFFER_HIGH_WATER.get(this.configs);
settings.writeBufferLowWaterMark = GremlinConfig.SERVER_WRITE_BUFFER_LOW_WATER.get(this.configs);
this.server = new GremlinServer(settings);
ServerGremlinExecutor serverGremlinExecutor = Utils.getFieldValue(GremlinServer.class, this.server, "serverGremlinExecutor");
serverGremlinExecutor.getGraphManager().putGraph("graph", graph);
serverGremlinExecutor.getGraphManager().putTraversalSource("g", graph.traversal());
GremlinExecutor gremlinExecutor = Utils.getFieldValue(ServerGremlinExecutor.class, serverGremlinExecutor, "gremlinExecutor");
Bindings globalBindings = Utils.getFieldValue(GremlinExecutor.class, gremlinExecutor, "globalBindings");
globalBindings.put("graph", graph);
globalBindings.put("g", graph.traversal());
ProcessorLoader processorLoader = new ReadOnlyMaxGraphProcessorLoader(this.configs, this.graph, this.schemaFetcher, this.rpcAddressFetcher);
try {
processorLoader.loadProcessor(settings);
} catch (Exception e) {
throw new MaxGraphException(e);
}
try {
this.server.start().exceptionally(t -> {
logger.error("Gremlin Server was unable to start and will now begin" + " shutdown: {}", t.getMessage());
this.server.stop().join();
return null;
}).join();
} catch (Exception e) {
throw new RuntimeException(e);
}
logger.info("Gremlin Server started....");
}
use of com.alibaba.maxgraph.server.ProcessorLoader in project GraphScope by alibaba.
the class GaiaGraphServer method start.
@Override
public void start(int port, ProcessorLoader processorLoader, boolean hasAuth) {
logger.info(GremlinServer.getHeader());
this.settings.port = instanceConfig.getGremlinServerPort();
this.settings.host = "0.0.0.0";
if (settings.gremlinPool == 0) {
settings.gremlinPool = Runtime.getRuntime().availableProcessors();
}
this.server = new GremlinServer(settings);
loadProcessor(gaiaConfig, broadcastProcessor, storeService);
// bind g to traversal source
Graph traversalGraph = TraversalSourceGraph.open(new BaseConfiguration());
ServerGremlinExecutor serverGremlinExecutor = PlanUtils.getServerGremlinExecutor(this.server);
serverGremlinExecutor.getGraphManager().putGraph("graph", traversalGraph);
serverGremlinExecutor.getGraphManager().putTraversalSource("g", traversalGraph.traversal());
Bindings globalBindings = PlanUtils.getGlobalBindings(server.getServerGremlinExecutor().getGremlinExecutor());
globalBindings.put("graph", traversalGraph);
globalBindings.put("g", traversalGraph.traversal());
// start gremlin server
try {
server.start().exceptionally(t -> {
logger.error("Gremlin Server was unable to start and will now begin" + " shutdown {}", t);
server.stop().join();
return null;
}).join();
} catch (Exception e) {
throw new RuntimeException(e);
}
logger.info("Gremlin Server started....");
}
Aggregations