if(remoteStoreDef.getName().equals(storeName)) {
// if the store already exists, but doesn't match what we want to push, we need to worry
if(!remoteStoreDef.equals(newStoreDef)) {
// let's check to see if the key/value serializers are
// REALLY equal.
SerializerDefinition localKeySerializerDef = newStoreDef.getKeySerializer();
SerializerDefinition localValueSerializerDef = newStoreDef.getValueSerializer();
SerializerDefinition remoteKeySerializerDef = remoteStoreDef.getKeySerializer();
SerializerDefinition remoteValueSerializerDef = remoteStoreDef.getValueSerializer();
if(remoteKeySerializerDef.getName().equals(serializerName)
&& remoteValueSerializerDef.getName().equals(serializerName)) {
Schema remoteKeyDef = Schema.parse(remoteKeySerializerDef.getCurrentSchemaInfo());
Schema remoteValDef = Schema.parse(remoteValueSerializerDef.getCurrentSchemaInfo());
Schema localKeyDef = Schema.parse(localKeySerializerDef.getCurrentSchemaInfo());
Schema localValDef = Schema.parse(localValueSerializerDef.getCurrentSchemaInfo());
if(remoteKeyDef.equals(localKeyDef) && remoteValDef.equals(localValDef)) {
String compressionPolicy = "";
if(hasCompression) {
compressionPolicy = "\n\t\t<compression><type>gzip</type></compression>";
}
// if the key/value serializers are REALLY equal
// (even though the strings may not match), then
// just use the remote stores to GUARANTEE that
// they
// match, and try again.
String keySerializerStr = "\n\t\t<type>"
+ remoteKeySerializerDef.getName()
+ "</type>";
if(remoteKeySerializerDef.hasVersion()) {
Map<Integer, String> versions = new HashMap<Integer, String>();
for(Map.Entry<Integer, String> entry: remoteKeySerializerDef.getAllSchemaInfoVersions()
.entrySet()) {
keySerializerStr += "\n\t\t <schema-info version=\""
+ entry.getKey() + "\">"
+ entry.getValue()
+ "</schema-info>\n\t";
}
} else {
keySerializerStr = "\n\t\t<type>"
+ serializerName
+ "</type>\n\t\t<schema-info version=\"0\">"
+ remoteKeySerializerDef.getCurrentSchemaInfo()
+ "</schema-info>\n\t";
}
schemaObj.keySchema = keySerializerStr;
String valueSerializerStr = "\n\t\t<type>"
+ remoteValueSerializerDef.getName()
+ "</type>";
if(remoteValueSerializerDef.hasVersion()) {
Map<Integer, String> versions = new HashMap<Integer, String>();
for(Map.Entry<Integer, String> entry: remoteValueSerializerDef.getAllSchemaInfoVersions()
.entrySet()) {
valueSerializerStr += "\n\t\t <schema-info version=\""
+ entry.getKey() + "\">"
+ entry.getValue()
+ "</schema-info>\n\t";
}
valueSerializerStr += compressionPolicy + "\n\t";
} else {
valueSerializerStr = "\n\t\t<type>"
+ serializerName
+ "</type>\n\t\t<schema-info version=\"0\">"
+ remoteValueSerializerDef.getCurrentSchemaInfo()
+ "</schema-info>" + compressionPolicy
+ "\n\t";
}
schemaObj.valSchema = valueSerializerStr;