@SuppressWarnings("deprecation")
@Override
public void upgrade(InteractionProtocol protocol) {
ZkClient zkClient = protocol.getZkClient();
ZkConfiguration zkConf = protocol.getZkConfiguration();
ZkClient zkClientForWriables = new ZkClient(zkConf.getZKServers(), 5000, 5000, new WriteableZkSerializer(
net.sf.katta.index.IndexMetaData.class));
LOG.info("restoring indices meta data...");
String oldIndicesPath = getOldIndicesPath(zkConf);
List<String> indices = zkClient.getChildren(oldIndicesPath);
LOG.info("found " + indices.size() + " old indices");
for (String indexName : indices) {
net.sf.katta.index.IndexMetaData oldIndexMD = zkClientForWriables.readData(oldIndicesPath + "/" + indexName);
IndexMetaData newIndexMD = new IndexMetaData(indexName, oldIndexMD.getPath(), oldIndexMD.getReplicationLevel());
IndexReinitializeOperation deployOperation = new IndexReinitializeOperation(newIndexMD);
protocol.addMasterOperation(deployOperation);
protocol.publishIndex(newIndexMD);
}
zkClientForWriables.close();
LOG.info("deleting obsolete folders...");
zkClient.deleteRecursive(zkConf.getZkRootPath() + "/" + "indexes");
zkClient.deleteRecursive(zkConf.getZkRootPath() + "/" + "node-to-shard");
zkClient.deleteRecursive(zkConf.getZkRootPath() + "/" + "shard-to-node");
zkClient.deleteRecursive(zkConf.getZkRootPath() + "/" + "loadtest-nodes");
zkClient.deleteRecursive(zkConf.getZkRootPath() + "/" + "server-metrics");
zkClient.deleteRecursive(zkConf.getZkRootPath() + "/" + "shard-to-error");
LOG.info("upgrade done");
}