Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

pushed instantiation of the view class from StoreDefinitionsMapper to…

… the ViewStorageConfiguration
  • Loading branch information...
commit d4c50f32b5f92eb7cbfa024ddd275df7f2795249 1 parent fb84aaa
@nehanarkhede nehanarkhede authored
View
3  src/java/voldemort/client/MockStoreClientFactory.java
@@ -31,6 +31,7 @@
import voldemort.store.serialized.SerializingStore;
import voldemort.store.versioned.InconsistencyResolvingStore;
import voldemort.store.versioned.VersionIncrementingStore;
+import voldemort.store.views.ViewStorageConfiguration;
import voldemort.store.views.ViewStorageEngine;
import voldemort.utils.SystemTime;
import voldemort.utils.Time;
@@ -184,7 +185,7 @@ public MockStoreClientFactory(Serializer<?> keySerializer,
this.valueSerializer != null ? this.valueSerializer
: serializerFactory.getSerializer(targetDef.getValueSerializer()),
null,
- storeDef.getValueTransformation());
+ ViewStorageConfiguration.loadTransformation(storeDef.getValueTransformation()));
}
Store store = new VersionIncrementingStore(engine, nodeId, time);
View
7 src/java/voldemort/store/StoreDefinition.java
@@ -20,7 +20,6 @@
import voldemort.client.RoutingTier;
import voldemort.serialization.SerializerDefinition;
-import voldemort.store.views.View;
import voldemort.utils.Utils;
import com.google.common.base.Objects;
@@ -49,7 +48,7 @@
private final Integer retentionScanThrottleRate;
private final String routingStrategyType;
private final String viewOf;
- private final View<?, ?, ?, ?> valueTransformation;
+ private final String valueTransformation;
private final String serializerFactory;
public StoreDefinition(String name,
@@ -65,7 +64,7 @@ public StoreDefinition(String name,
Integer preferredWrites,
int requiredWrites,
String viewOfStore,
- View<?, ?, ?, ?> valTrans,
+ String valTrans,
Integer retentionDays,
Integer retentionThrottleRate,
String factory) {
@@ -205,7 +204,7 @@ public boolean hasValueTransformation() {
return this.valueTransformation != null;
}
- public View<?, ?, ?, ?> getValueTransformation() {
+ public String getValueTransformation() {
return valueTransformation;
}
View
7 src/java/voldemort/store/StoreDefinitionBuilder.java
@@ -2,7 +2,6 @@
import voldemort.client.RoutingTier;
import voldemort.serialization.SerializerDefinition;
-import voldemort.store.views.View;
import voldemort.utils.Utils;
/**
@@ -28,7 +27,7 @@
private Integer retentionScanThrottleRate = null;
private String routingStrategyType = null;
private String viewOf = null;
- private View<?, ?, ?, ?> view = null;
+ private String view = null;
private String serializerFactory = null;
public String getName() {
@@ -182,11 +181,11 @@ public StoreDefinitionBuilder setViewOf(String viewOf) {
return this;
}
- public View<?, ?, ?, ?> getView() {
+ public String getView() {
return view;
}
- public StoreDefinitionBuilder setView(View<?, ?, ?, ?> valueTransformation) {
+ public StoreDefinitionBuilder setView(String valueTransformation) {
this.view = valueTransformation;
return this;
}
View
18 src/java/voldemort/store/views/ViewStorageConfiguration.java
@@ -55,6 +55,10 @@ public void close() {}
valueCompressionStrategy = new CompressionStrategyFactory().get(targetDef.getValueSerializer()
.getCompression());
}
+
+ /* instantiate the view class */
+ View<?, ?, ?, ?> view = loadTransformation(def.getValueTransformation());
+
return new ViewStorageEngine(name,
target,
factory.getSerializer(def.getValueSerializer()),
@@ -63,18 +67,24 @@ public void close() {}
factory.getSerializer(targetDef.getKeySerializer()),
factory.getSerializer(targetDef.getValueSerializer()),
valueCompressionStrategy,
- def.getValueTransformation());
+ view);
}
public String getType() {
return TYPE_NAME;
}
- private SerializerFactory loadSerializerFactory(String className) {
+ public static SerializerFactory loadSerializerFactory(String className) {
if(className == null)
return null;
- Class<?> transClass = ReflectUtils.loadClass(className.trim());
- return (SerializerFactory) ReflectUtils.callConstructor(transClass, new Object[] {});
+ Class<?> factoryClass = ReflectUtils.loadClass(className.trim());
+ return (SerializerFactory) ReflectUtils.callConstructor(factoryClass, new Object[] {});
}
+ public static View<?, ?, ?, ?> loadTransformation(String className) {
+ if(className == null)
+ return null;
+ Class<?> viewClass = ReflectUtils.loadClass(className.trim());
+ return (View<?, ?, ?, ?>) ReflectUtils.callConstructor(viewClass, new Object[] {});
+ }
}
View
19 src/java/voldemort/xml/StoreDefinitionsMapper.java
@@ -48,9 +48,7 @@
import voldemort.store.StoreDefinition;
import voldemort.store.StoreDefinitionBuilder;
import voldemort.store.StoreUtils;
-import voldemort.store.views.View;
import voldemort.store.views.ViewStorageConfiguration;
-import voldemort.utils.ReflectUtils;
/**
* Parses a stores.xml file
@@ -236,8 +234,8 @@ private StoreDefinition readView(Element store, List<StoreDefinition> stores) {
if(store.getChild(STORE_ROUTING_STRATEGY) != null)
policy = RoutingTier.fromDisplay(store.getChildText(STORE_ROUTING_STRATEGY));
- // get transformations
- View<?, ?, ?, ?> valTrans = loadTransformation(store.getChildText(VIEW_TRANS_ELMT));
+ // get view class name
+ String viewClass = store.getChildText(VIEW_TRANS_ELMT);
return new StoreDefinitionBuilder().setName(name)
.setViewOf(targetName)
@@ -252,18 +250,11 @@ private StoreDefinition readView(Element store, List<StoreDefinition> stores) {
.setRequiredReads(requiredReads)
.setPreferredWrites(preferredWrites)
.setRequiredWrites(requiredWrites)
- .setView(valTrans)
+ .setView(viewClass)
.setSerializerFactory(viewSerializerFactoryName)
.build();
}
- private View<?, ?, ?, ?> loadTransformation(String className) {
- if(className == null)
- return null;
- Class<?> transClass = ReflectUtils.loadClass(className.trim());
- return (View<?, ?, ?, ?>) ReflectUtils.callConstructor(transClass, new Object[] {});
- }
-
private SerializerDefinition readSerializer(Element elmt) {
String name = elmt.getChild(STORE_SERIALIZATION_TYPE_ELMT).getText();
boolean hasVersion = true;
@@ -355,9 +346,7 @@ private Element viewToElement(StoreDefinition storeDefinition) {
if(storeDefinition.getValueTransformation() == null)
throw new MappingException("View " + storeDefinition.getName()
+ " has no defined transformation class.");
- store.addContent(new Element(VIEW_TRANS_ELMT).setText(storeDefinition.getValueTransformation()
- .getClass()
- .getName()));
+ store.addContent(new Element(VIEW_TRANS_ELMT).setText(storeDefinition.getValueTransformation()));
store.addContent(new Element(STORE_ROUTING_TIER_ELMT).setText(storeDefinition.getRoutingPolicy()
.toDisplay()));
if(storeDefinition.hasPreferredReads())
Please sign in to comment.
Something went wrong with that request. Please try again.