Java Code Examples for org.apache.ratis.statemachine.StateMachine#Registry
The following examples show how to use
org.apache.ratis.statemachine.StateMachine#Registry .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServerImplUtils.java From incubator-ratis with Apache License 2.0 | 6 votes |
public static RaftServerProxy newRaftServer( RaftPeerId id, StateMachine.Registry stateMachineRegistry, RaftProperties properties, Parameters parameters) throws IOException { final TimeDuration sleepTime = TimeDuration.valueOf(500, TimeUnit.MILLISECONDS); final RaftServerProxy proxy; try { // attempt multiple times to avoid temporary bind exception proxy = JavaUtils.attemptRepeatedly( () -> new RaftServerProxy(id, stateMachineRegistry, properties, parameters), 5, sleepTime, "new RaftServerProxy", RaftServerProxy.LOG); } catch (InterruptedException e) { throw IOUtils.toInterruptedIOException( "Interrupted when creating RaftServer " + id, e); } return proxy; }
Example 2
Source File: MiniRaftClusterWithHadoopRpc.java From ratis with Apache License 2.0 | 5 votes |
@Override protected RaftServerProxy newRaftServer( RaftPeerId id, StateMachine.Registry stateMachineRegistry , RaftGroup group, RaftProperties properties) throws IOException { final Configuration hconf = new Configuration(hadoopConf); final String address = "0.0.0.0:" + getPort(id, group); HadoopConfigKeys.Ipc.setAddress(hconf, address); return ServerImplUtils.newRaftServer(id, group, stateMachineRegistry, properties, HadoopFactory.newRaftParameters(hconf)); }
Example 3
Source File: MiniRaftClusterWithSimulatedRpc.java From ratis with Apache License 2.0 | 5 votes |
@Override protected RaftServerProxy newRaftServer( RaftPeerId id, StateMachine.Registry stateMachineRegistry , RaftGroup group, RaftProperties properties) throws IOException { serverRequestReply.addPeer(id); client2serverRequestReply.addPeer(id); return ServerImplUtils.newRaftServer(id, group, stateMachineRegistry, properties, parameters); }
Example 4
Source File: ServerImplUtils.java From ratis with Apache License 2.0 | 5 votes |
private static RaftServerProxy newRaftServer( RaftPeerId id, StateMachine.Registry stateMachineRegistry, RaftProperties properties, Parameters parameters) throws IOException { final RaftServerProxy proxy; try { // attempt multiple times to avoid temporary bind exception proxy = JavaUtils.attempt( () -> new RaftServerProxy(id, stateMachineRegistry, properties, parameters), 5, 500L, "new RaftServerProxy", RaftServerProxy.LOG); } catch (InterruptedException e) { throw IOUtils.toInterruptedIOException( "Interrupted when creating RaftServer " + id, e); } return proxy; }
Example 5
Source File: ServerImplUtils.java From ratis with Apache License 2.0 | 5 votes |
/** For the case that all {@link RaftServerImpl} objects share the same {@link StateMachine}. */ public static RaftServerProxy newRaftServer( RaftPeerId id, RaftGroup group, StateMachine.Registry stateMachineRegistry, RaftProperties properties, Parameters parameters) throws IOException { RaftServerProxy.LOG.debug("newRaftServer: {}, {}", id, group); final RaftServerProxy proxy = newRaftServer(id, stateMachineRegistry, properties, parameters); proxy.initGroups(group); return proxy; }
Example 6
Source File: RaftServerProxy.java From ratis with Apache License 2.0 | 5 votes |
RaftServerProxy(RaftPeerId id, StateMachine.Registry stateMachineRegistry, RaftProperties properties, Parameters parameters) { this.properties = properties; this.stateMachineRegistry = stateMachineRegistry; final RpcType rpcType = RaftConfigKeys.Rpc.type(properties, LOG::info); this.factory = ServerFactory.cast(rpcType.newFactory(parameters)); this.serverRpc = factory.newRaftServerRpc(this); this.id = id != null? id: RaftPeerId.valueOf(getIdStringFrom(serverRpc)); this.lifeCycle = new LifeCycle(this.id + "-" + getClass().getSimpleName()); }
Example 7
Source File: MiniRaftClusterWithNetty.java From ratis with Apache License 2.0 | 5 votes |
@Override protected RaftServerProxy newRaftServer( RaftPeerId id, StateMachine.Registry stateMachineRegistry , RaftGroup group, RaftProperties properties) throws IOException { NettyConfigKeys.Server.setPort(properties, getPort(id, group)); return ServerImplUtils.newRaftServer(id, group, stateMachineRegistry, properties, null); }
Example 8
Source File: MiniRaftClusterWithGrpc.java From ratis with Apache License 2.0 | 5 votes |
@Override protected RaftServerProxy newRaftServer( RaftPeerId id, StateMachine.Registry stateMachineRegistry, RaftGroup group, RaftProperties properties) throws IOException { GrpcConfigKeys.Server.setPort(properties, getPort(id, group)); return ServerImplUtils.newRaftServer(id, group, stateMachineRegistry, properties, null); }
Example 9
Source File: MiniRaftClusterWithHadoopRpc.java From incubator-ratis with Apache License 2.0 | 5 votes |
@Override protected RaftServerProxy newRaftServer( RaftPeerId id, StateMachine.Registry stateMachineRegistry , RaftGroup group, RaftProperties properties) throws IOException { final Configuration hconf = new Configuration(hadoopConf); final String address = "0.0.0.0:" + getPort(id, group); HadoopConfigKeys.Ipc.setAddress(hconf, address); return ServerImplUtils.newRaftServer(id, group, stateMachineRegistry, properties, HadoopFactory.newRaftParameters(hconf)); }
Example 10
Source File: MiniRaftClusterWithSimulatedRpc.java From incubator-ratis with Apache License 2.0 | 5 votes |
@Override protected RaftServerProxy newRaftServer( RaftPeerId id, StateMachine.Registry stateMachineRegistry , RaftGroup group, RaftProperties properties) throws IOException { serverRequestReply.addPeer(id); client2serverRequestReply.addPeer(id); return ServerImplUtils.newRaftServer(id, group, stateMachineRegistry, properties, parameters); }
Example 11
Source File: ServerImplUtils.java From incubator-ratis with Apache License 2.0 | 5 votes |
/** For the case that all {@link RaftServerImpl} objects share the same {@link StateMachine}. */ public static RaftServerProxy newRaftServer( RaftPeerId id, RaftGroup group, StateMachine.Registry stateMachineRegistry, RaftProperties properties, Parameters parameters) throws IOException { RaftServerProxy.LOG.debug("newRaftServer: {}, {}", id, group); final RaftServerProxy proxy = newRaftServer(id, stateMachineRegistry, properties, parameters); proxy.initGroups(group); return proxy; }
Example 12
Source File: RaftServerProxy.java From incubator-ratis with Apache License 2.0 | 5 votes |
RaftServerProxy(RaftPeerId id, StateMachine.Registry stateMachineRegistry, RaftProperties properties, Parameters parameters) { this.properties = properties; this.stateMachineRegistry = stateMachineRegistry; final RpcType rpcType = RaftConfigKeys.Rpc.type(properties, LOG::info); this.factory = ServerFactory.cast(rpcType.newFactory(parameters)); this.serverRpc = factory.newRaftServerRpc(this); this.id = id != null? id: RaftPeerId.valueOf(getIdStringFrom(serverRpc)); this.lifeCycle = new LifeCycle(this.id + "-" + getClass().getSimpleName()); this.implExecutor = Executors.newSingleThreadExecutor(); }
Example 13
Source File: MiniRaftClusterWithNetty.java From incubator-ratis with Apache License 2.0 | 5 votes |
@Override protected RaftServerProxy newRaftServer( RaftPeerId id, StateMachine.Registry stateMachineRegistry , RaftGroup group, RaftProperties properties) throws IOException { NettyConfigKeys.Server.setPort(properties, getPort(id, group)); return ServerImplUtils.newRaftServer(id, group, stateMachineRegistry, properties, null); }
Example 14
Source File: MiniRaftClusterWithGrpc.java From incubator-ratis with Apache License 2.0 | 5 votes |
@Override protected RaftServerProxy newRaftServer( RaftPeerId id, StateMachine.Registry stateMachineRegistry, RaftGroup group, RaftProperties properties) throws IOException { GrpcConfigKeys.Server.setPort(properties, getPort(id, group)); return ServerImplUtils.newRaftServer(id, group, stateMachineRegistry, properties, null); }
Example 15
Source File: MiniRaftCluster.java From incubator-ratis with Apache License 2.0 | 4 votes |
public void setStateMachineRegistry(StateMachine.Registry stateMachineRegistry) { this.stateMachineRegistry = stateMachineRegistry; }
Example 16
Source File: MiniRaftCluster.java From incubator-ratis with Apache License 2.0 | 4 votes |
protected abstract RaftServerProxy newRaftServer( RaftPeerId id, StateMachine.Registry stateMachineRegistry , RaftGroup group, RaftProperties properties) throws IOException;
Example 17
Source File: RaftServer.java From incubator-ratis with Apache License 2.0 | 4 votes |
/** Set the {@link StateMachine.Registry} of the server. */ public Builder setStateMachineRegistry(StateMachine.Registry stateMachineRegistry ) { this.stateMachineRegistry = stateMachineRegistry ; return this; }
Example 18
Source File: RaftServer.java From ratis with Apache License 2.0 | 4 votes |
/** Set the {@link StateMachine.Registry} of the server. */ public Builder setStateMachineRegistry(StateMachine.Registry stateMachineRegistry ) { this.stateMachineRegistry = stateMachineRegistry ; return this; }
Example 19
Source File: MiniRaftCluster.java From ratis with Apache License 2.0 | 4 votes |
protected abstract RaftServerProxy newRaftServer( RaftPeerId id, StateMachine.Registry stateMachineRegistry , RaftGroup group, RaftProperties properties) throws IOException;
Example 20
Source File: MiniRaftCluster.java From ratis with Apache License 2.0 | 4 votes |
public void setStateMachineRegistry(StateMachine.Registry stateMachineRegistry) { this.stateMachineRegistry = stateMachineRegistry; }