Skip to content

Commit

Permalink
Merge branch 'server-transforms' into server-transforms-network
Browse files Browse the repository at this point in the history
  • Loading branch information
afeinberg committed Jun 24, 2010
2 parents 61a91cc + fea5393 commit 4dd8512
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
12 changes: 5 additions & 7 deletions src/java/voldemort/store/StoreDefinition.java
Expand Up @@ -20,7 +20,6 @@

import voldemort.client.RoutingTier;
import voldemort.serialization.SerializerDefinition;
import voldemort.serialization.SerializerFactory;
import voldemort.store.views.View;
import voldemort.utils.Utils;

Expand Down Expand Up @@ -51,7 +50,7 @@ public class StoreDefinition implements Serializable {
private final String routingStrategyType;
private final String viewOf;
private final View<?, ?, ?, ?> valueTransformation;
private final SerializerFactory serializerFactory;
private final String serializerFactory;

public StoreDefinition(String name,
String type,
Expand All @@ -69,7 +68,7 @@ public StoreDefinition(String name,
View<?, ?, ?, ?> valTrans,
Integer retentionDays,
Integer retentionThrottleRate,
SerializerFactory factory) {
String factory) {
this.name = Utils.notNull(name);
this.type = Utils.notNull(type);
this.replicationFactor = replicationFactor;
Expand Down Expand Up @@ -210,7 +209,7 @@ public boolean hasValueTransformation() {
return valueTransformation;
}

public SerializerFactory getSerializerFactory() {
public String getSerializerFactory() {
return this.serializerFactory;
}

Expand Down Expand Up @@ -245,10 +244,9 @@ && getRoutingPolicy() == def.getRoutingPolicy()
.getClass() : null)
&& Objects.equal(getRetentionDays(), def.getRetentionDays())
&& Objects.equal(getRetentionScanThrottleRate(), def.getRetentionScanThrottleRate())
&& Objects.equal(getSerializerFactory() != null ? getSerializerFactory().getClass()
: null,
&& Objects.equal(getSerializerFactory() != null ? getSerializerFactory() : null,
def.getSerializerFactory() != null ? def.getSerializerFactory()
.getClass() : null);
: null);
}

@Override
Expand Down
7 changes: 3 additions & 4 deletions src/java/voldemort/store/StoreDefinitionBuilder.java
Expand Up @@ -2,7 +2,6 @@

import voldemort.client.RoutingTier;
import voldemort.serialization.SerializerDefinition;
import voldemort.serialization.SerializerFactory;
import voldemort.store.views.View;
import voldemort.utils.Utils;

Expand Down Expand Up @@ -30,7 +29,7 @@ public class StoreDefinitionBuilder {
private String routingStrategyType = null;
private String viewOf = null;
private View<?, ?, ?, ?> view = null;
private SerializerFactory serializerFactory = null;
private String serializerFactory = null;

public String getName() {
return Utils.notNull(name);
Expand Down Expand Up @@ -192,11 +191,11 @@ public StoreDefinitionBuilder setView(View<?, ?, ?, ?> valueTransformation) {
return this;
}

public SerializerFactory getSerializerFactory() {
public String getSerializerFactory() {
return this.serializerFactory;
}

public StoreDefinitionBuilder setSerializerFactory(SerializerFactory factory) {
public StoreDefinitionBuilder setSerializerFactory(String factory) {
this.serializerFactory = factory;
return this;
}
Expand Down
16 changes: 14 additions & 2 deletions src/java/voldemort/store/views/ViewStorageConfiguration.java
Expand Up @@ -14,6 +14,7 @@
import voldemort.store.compress.CompressionStrategy;
import voldemort.store.compress.CompressionStrategyFactory;
import voldemort.utils.ByteArray;
import voldemort.utils.ReflectUtils;
import voldemort.utils.Utils;

public class ViewStorageConfiguration implements StorageConfiguration {
Expand Down Expand Up @@ -41,9 +42,13 @@ public StorageEngine<ByteArray, byte[], byte[]> getStore(String name) {
if(target == null)
throw new VoldemortException("View \"" + name + "\" has a target store \"" + targetName
+ "\" which does not exist.");
SerializerFactory factory = def.getSerializerFactory();
if(factory == null)
String factoryName = def.getSerializerFactory();
SerializerFactory factory;
if(factoryName == null)
factory = new DefaultSerializerFactory();
else
factory = loadSerializerFactory(factoryName);

/* Check if the values in the target store are compressed */
CompressionStrategy valueCompressionStrategy = null;
if(targetDef.getValueSerializer().hasCompression()) {
Expand All @@ -65,4 +70,11 @@ public String getType() {
return TYPE_NAME;
}

private SerializerFactory loadSerializerFactory(String className) {
if(className == null)
return null;
Class<?> transClass = ReflectUtils.loadClass(className.trim());
return (SerializerFactory) ReflectUtils.callConstructor(transClass, new Object[] {});
}

}
17 changes: 4 additions & 13 deletions src/java/voldemort/xml/StoreDefinitionsMapper.java
Expand Up @@ -45,7 +45,6 @@
import voldemort.routing.RoutingStrategyType;
import voldemort.serialization.Compression;
import voldemort.serialization.SerializerDefinition;
import voldemort.serialization.SerializerFactory;
import voldemort.store.StoreDefinition;
import voldemort.store.StoreDefinitionBuilder;
import voldemort.store.StoreUtils;
Expand Down Expand Up @@ -219,10 +218,9 @@ private StoreDefinition readView(Element store, List<StoreDefinition> stores) {
STORE_PREFERRED_WRITES_ELMT,
target.getRequiredReads());

SerializerFactory viewSerializerFactory = null;
String viewSerializerFactoryName = null;
if(store.getChildText(VIEW_SERIALIZER_FACTORY_ELMT) != null) {
String serializerFactoryName = store.getChild(VIEW_SERIALIZER_FACTORY_ELMT).getText();
viewSerializerFactory = loadSerializerFactory(serializerFactoryName);
viewSerializerFactoryName = store.getChild(VIEW_SERIALIZER_FACTORY_ELMT).getText();
}

SerializerDefinition keySerializer = target.getKeySerializer();
Expand Down Expand Up @@ -255,7 +253,7 @@ private StoreDefinition readView(Element store, List<StoreDefinition> stores) {
.setPreferredWrites(preferredWrites)
.setRequiredWrites(requiredWrites)
.setView(valTrans)
.setSerializerFactory(viewSerializerFactory)
.setSerializerFactory(viewSerializerFactoryName)
.build();
}

Expand All @@ -266,13 +264,6 @@ private StoreDefinition readView(Element store, List<StoreDefinition> stores) {
return (View<?, ?, ?, ?>) ReflectUtils.callConstructor(transClass, new Object[] {});
}

private SerializerFactory loadSerializerFactory(String className) {
if(className == null)
return null;
Class<?> transClass = ReflectUtils.loadClass(className.trim());
return (SerializerFactory) ReflectUtils.callConstructor(transClass, new Object[] {});
}

private SerializerDefinition readSerializer(Element elmt) {
String name = elmt.getChild(STORE_SERIALIZATION_TYPE_ELMT).getText();
boolean hasVersion = true;
Expand Down Expand Up @@ -388,7 +379,7 @@ private Element viewToElement(StoreDefinition storeDefinition) {

Element serializerFactory = new Element(VIEW_SERIALIZER_FACTORY_ELMT);
if(storeDefinition.getSerializerFactory() != null) {
serializerFactory.setText(storeDefinition.getSerializerFactory().getClass().getName());
serializerFactory.setText(storeDefinition.getSerializerFactory());
store.addContent(serializerFactory);
}
return store;
Expand Down

0 comments on commit 4dd8512

Please sign in to comment.