public static ClusterConfiguration fromBytes(ByteBuffer buffer){ ClusterConfiguration configuration = new ClusterConfiguration(); configuration.setLogIndex(buffer.getLong()); configuration.setLastLogIndex(buffer.getLong()); while(buffer.hasRemaining()){ configuration.getServers().add(new ClusterServer(buffer)); } return configuration; }
/** * 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 buffer the binary data * @return cluster configuration */ public static ClusterConfiguration fromBytes(ByteBuffer buffer){ ClusterConfiguration configuration = new ClusterConfiguration(); configuration.setLogIndex(buffer.getLong()); configuration.setLastLogIndex(buffer.getLong()); while(buffer.hasRemaining()){ configuration.getServers().add(new ClusterServer(buffer)); } return configuration; }
/** * 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 buffer the binary data * @return cluster configuration */ public static ClusterConfiguration fromBytes(ByteBuffer buffer){ ClusterConfiguration configuration = new ClusterConfiguration(); configuration.setLogIndex(buffer.getLong()); configuration.setLastLogIndex(buffer.getLong()); while(buffer.hasRemaining()){ configuration.getServers().add(new ClusterServer(buffer)); } return configuration; }
private void removeServerFromCluster(int serverId){ ClusterConfiguration newConfig = new ClusterConfiguration(); newConfig.setLastLogIndex(this.config.getLogIndex()); newConfig.setLogIndex(this.logStore.getFirstAvailableIndex()); for(ClusterServer server: this.config.getServers()){ if(server.getId() != serverId){ newConfig.getServers().add(server); } } this.logger.info("removed a server from configuration and save the configuration to log store at %d", newConfig.getLogIndex()); this.configChanging = true; this.logStore.append(new LogEntry(this.state.getTerm(), newConfig.toBytes(), LogValueType.Configuration)); this.requestAppendEntries(); }
private void removeServerFromCluster(int serverId){ ClusterConfiguration newConfig = new ClusterConfiguration(); newConfig.setLastLogIndex(this.config.getLogIndex()); newConfig.setLogIndex(this.logStore.getFirstAvailableIndex()); for(ClusterServer server: this.config.getServers()){ if(server.getId() != serverId){ newConfig.getServers().add(server); } } this.logger.info("removed a server from configuration and save the configuration to log store at %d", newConfig.getLogIndex()); this.configChanging = true; this.logStore.append(new LogEntry(this.state.getTerm(), newConfig.toBytes(), LogValueType.Configuration)); this.requestAppendEntries(); }
private void removeServerFromCluster(int serverId){ ClusterConfiguration newConfig = new ClusterConfiguration(); newConfig.setLastLogIndex(this.config.getLogIndex()); newConfig.setLogIndex(this.logStore.getFirstAvailableIndex()); for(ClusterServer server: this.config.getServers()){ if(server.getId() != serverId){ newConfig.getServers().add(server); } } this.logger.info("removed a server from configuration and save the configuration to log store at %d", newConfig.getLogIndex()); this.configChanging = true; this.logStore.append(new LogEntry(this.state.getTerm(), newConfig.toBytes(), LogValueType.Configuration)); this.requestAppendEntries(); }
ClusterConfiguration newConfig = new ClusterConfiguration(); newConfig.setLastLogIndex(this.config.getLogIndex()); newConfig.setLogIndex(this.logStore.getFirstAvailableIndex());
ClusterConfiguration newConfig = new ClusterConfiguration(); newConfig.setLastLogIndex(this.config.getLogIndex()); newConfig.setLogIndex(this.logStore.getFirstAvailableIndex());
ClusterConfiguration newConfig = new ClusterConfiguration(); newConfig.setLastLogIndex(this.config.getLogIndex()); newConfig.setLogIndex(this.logStore.getFirstAvailableIndex());