public ClusterSchema loadClusterSchema(ObjectId id_cluster_schema, List<SlaveServer> slaveServers) throws KettleException { ClusterSchema clusterSchema = new ClusterSchema(); RowMetaAndData row = getClusterSchema(id_cluster_schema); clusterSchema.setObjectId(id_cluster_schema); clusterSchema.setName(row.getString(KettleDatabaseRepository.FIELD_CLUSTER_NAME, null)); clusterSchema.setBasePort( row.getString(KettleDatabaseRepository.FIELD_CLUSTER_BASE_PORT, null)); clusterSchema.setSocketsBufferSize( row.getString(KettleDatabaseRepository.FIELD_CLUSTER_SOCKETS_BUFFER_SIZE, null)); clusterSchema.setSocketsFlushInterval( row.getString(KettleDatabaseRepository.FIELD_CLUSTER_SOCKETS_FLUSH_INTERVAL, null)); clusterSchema.setSocketsCompressed( row.getBoolean(KettleDatabaseRepository.FIELD_CLUSTER_SOCKETS_COMPRESSED, true)); clusterSchema.setDynamic(row.getBoolean(KettleDatabaseRepository.FIELD_CLUSTER_DYNAMIC, true)); ObjectId[] pids = repository.getClusterSlaveIDs(id_cluster_schema); for (int i = 0; i < pids.length; i++) { SlaveServer slaveServer = repository.loadSlaveServer(pids[i], null); // Load last version SlaveServer reference = SlaveServer.findSlaveServer(slaveServers, slaveServer.getName()); if (reference != null) { clusterSchema.getSlaveServers().add(reference); } else { clusterSchema.getSlaveServers().add(slaveServer); } } return clusterSchema; }
public ClusterSchema decodeClusterSchema( JSONObject jsonObject, List<SlaveServer> referenceSlaveServers) { ClusterSchema clusterSchema = new ClusterSchema(); clusterSchema.setName(jsonObject.optString("name")); clusterSchema.setBasePort(jsonObject.optString("base_port")); clusterSchema.setSocketsBufferSize(jsonObject.optString("sockets_buffer_size")); clusterSchema.setSocketsFlushInterval(jsonObject.optString("sockets_flush_interval")); clusterSchema.setSocketsCompressed( "Y".equalsIgnoreCase(jsonObject.optString("sockets_compressed"))); clusterSchema.setDynamic("Y".equalsIgnoreCase(jsonObject.optString("dynamic"))); ArrayList<SlaveServer> slaveServers = new ArrayList<SlaveServer>(); JSONArray slavesNode = jsonObject.optJSONArray("slaveservers"); if (slavesNode != null) { for (int i = 0; i < slavesNode.size(); i++) { JSONObject slaveServerJson = slavesNode.getJSONObject(i); SlaveServer slaveServer = SlaveServer.findSlaveServer(referenceSlaveServers, slaveServerJson.optString("name")); if (slaveServer != null) { slaveServers.add(slaveServer); } } clusterSchema.setSlaveServers(slaveServers); } return clusterSchema; }