/** * De-serialize the data stored in buffer to cluster configuration * this is used for the peers to get the cluster configuration from log entry value * @param data the binary data * @return cluster configuration */ public static ClusterConfiguration fromBytes(byte[] data){ return fromBytes(ByteBuffer.wrap(data)); }
/** * De-serialize the data stored in buffer to cluster configuration * this is used for the peers to get the cluster configuration from log entry value * @param data the binary data * @return cluster configuration */ public static ClusterConfiguration fromBytes(byte[] data){ return fromBytes(ByteBuffer.wrap(data)); }
public static ClusterConfiguration fromBytes(byte[] data){ return fromBytes(ByteBuffer.wrap(data)); }
public static SnapshotSyncRequest fromBytes(byte[] bytes){ ByteBuffer buffer = ByteBuffer.wrap(bytes); long lastLogIndex = buffer.getLong(); long lastLogTerm = buffer.getLong(); int configSize = buffer.getInt(); ClusterConfiguration config = ClusterConfiguration.fromBytes(ByteBuffer.wrap(bytes, buffer.position(), configSize)); buffer.position(buffer.position() + configSize); long offset = buffer.getLong(); int dataSize = buffer.getInt(); byte[] data = new byte[dataSize]; buffer.get(data); boolean done = buffer.get() == 1; return new SnapshotSyncRequest(new Snapshot(lastLogIndex, lastLogTerm, config), offset, data, done); } }
public static SnapshotSyncRequest fromBytes(byte[] bytes){ ByteBuffer buffer = ByteBuffer.wrap(bytes); long lastLogIndex = buffer.getLong(); long lastLogTerm = buffer.getLong(); int configSize = buffer.getInt(); ClusterConfiguration config = ClusterConfiguration.fromBytes(ByteBuffer.wrap(bytes, buffer.position(), configSize)); buffer.position(buffer.position() + configSize); long offset = buffer.getLong(); int dataSize = buffer.getInt(); byte[] data = new byte[dataSize]; buffer.get(data); boolean done = buffer.get() == 1; return new SnapshotSyncRequest(new Snapshot(lastLogIndex, lastLogTerm, config), offset, data, done); } }
public static SnapshotSyncRequest fromBytes(byte[] bytes){ ByteBuffer buffer = ByteBuffer.wrap(bytes); long lastLogIndex = buffer.getLong(); long lastLogTerm = buffer.getLong(); int configSize = buffer.getInt(); ClusterConfiguration config = ClusterConfiguration.fromBytes(ByteBuffer.wrap(bytes, buffer.position(), configSize)); buffer.position(buffer.position() + configSize); long offset = buffer.getLong(); int dataSize = buffer.getInt(); byte[] data = new byte[dataSize]; buffer.get(data); boolean done = buffer.get() == 1; return new SnapshotSyncRequest(new Snapshot(lastLogIndex, lastLogTerm, config), offset, data, done); } }
if(latestSnapshot != null){ byte[] configData = Files.readAllBytes(this.snapshotStore.resolve(String.format("%d.cnf", maxLastLogIndex))); ClusterConfiguration config = ClusterConfiguration.fromBytes(configData); return new Snapshot(maxLastLogIndex, term, config, latestSnapshot.toFile().length());
if(latestSnapshot != null){ byte[] configData = Files.readAllBytes(this.snapshotStore.resolve(String.format("%d.cnf", maxLastLogIndex))); ClusterConfiguration config = ClusterConfiguration.fromBytes(configData); return new Snapshot(maxLastLogIndex, term, config, latestSnapshot.toFile().length());
}else if(logEntry.getValueType() == LogValueType.Configuration){ synchronized(server){ ClusterConfiguration newConfig = ClusterConfiguration.fromBytes(logEntry.getValue()); server.logger.info("configuration at index %d is committed", newConfig.getLogIndex()); server.context.getServerStateManager().saveClusterConfiguration(newConfig);
config = ClusterConfiguration.fromBytes(this.logStore.getLogEntryAt(config.getLastLogIndex()).getValue());
config = ClusterConfiguration.fromBytes(this.logStore.getLogEntryAt(config.getLastLogIndex()).getValue());
}else if(logEntry.getValueType() == LogValueType.Configuration){ synchronized(server){ ClusterConfiguration newConfig = ClusterConfiguration.fromBytes(logEntry.getValue()); server.logger.info("configuration at index %d is committed", newConfig.getLogIndex()); server.context.getServerStateManager().saveClusterConfiguration(newConfig);
config = ClusterConfiguration.fromBytes(this.logStore.getLogEntryAt(config.getLastLogIndex()).getValue());
}else if(logEntry.getValueType() == LogValueType.Configuration){ synchronized(server){ ClusterConfiguration newConfig = ClusterConfiguration.fromBytes(logEntry.getValue()); server.logger.info("configuration at index %d is committed", newConfig.getLogIndex()); server.context.getServerStateManager().saveClusterConfiguration(newConfig);
this.context.getServerStateManager().persistState(this.state); this.stopElectionTimer(); ClusterConfiguration newConfig = ClusterConfiguration.fromBytes(logEntries[0].getValue()); this.reconfigure(newConfig); response.setTerm(this.state.getTerm());
this.context.getServerStateManager().persistState(this.state); this.stopElectionTimer(); ClusterConfiguration newConfig = ClusterConfiguration.fromBytes(logEntries[0].getValue()); this.reconfigure(newConfig); response.setTerm(this.state.getTerm());
this.context.getServerStateManager().persistState(this.state); this.stopElectionTimer(); ClusterConfiguration newConfig = ClusterConfiguration.fromBytes(logEntries[0].getValue()); this.reconfigure(newConfig); response.setTerm(this.state.getTerm());