Permalink
Browse files

Some fixes for read-only store. Some misc. cleanup.

  • Loading branch information...
1 parent 7d77574 commit 9e864bc2c1e9b2d1bc153702add7af1501eb59c0 @jkreps jkreps committed Jan 13, 2009
View
@@ -22,7 +22,6 @@
<classpathentry kind="lib" path="lib/jetty-util-6.1.6rc0.jar"/>
<classpathentry kind="lib" path="lib/junit-4.1.jar"/>
<classpathentry kind="lib" path="lib/log4j-1.2.13.jar"/>
- <classpathentry kind="lib" path="lib/mysql-connector-java-5.1.5-bin.jar"/>
<classpathentry kind="lib" path="lib/servlet-api.jar"/>
<classpathentry kind="lib" path="lib/slf4j-api-1.4.3.jar"/>
<classpathentry kind="lib" path="lib/slf4j-log4j12-1.4.3.jar"/>
View
@@ -1,6 +1,6 @@
#Build Number for ANT. Do not edit!
-#Fri Jan 02 13:30:12 PST 2009
-build.number=139
+#Tue Jan 13 13:36:23 PST 2009
+build.number=142
>>>>>>>=1.8
-=\=\=\=\=\=\=
<<<<<<<=build_number.txt
+=\=\=\=\=\=\=
@@ -1,83 +1,18 @@
<stores>
- <store>
- <name>company</name>
- <persistence>read-only</persistence>
- <routing>client</routing>
- <replication-factor>1</replication-factor>
- <required-reads>1</required-reads>
+ <store>
+ <name>test</name>
+ <persistence>cache</persistence>
+ <routing>client</routing>
+ <replication-factor>1</replication-factor>
+ <required-reads>1</required-reads>
<required-writes>1</required-writes>
<key-serializer>
<type>json</type>
- <schema-info>"int32"</schema-info>
+ <schema-info>"string"</schema-info>
</key-serializer>
<value-serializer>
<type>json</type>
- <schema-info>
- {
- "company_id":"int32",
- "universal_name": "string",
- "company_size": "string",
- "company_type": "string",
- "industry": "int32",
- "symbol": "string",
- "company_url": "string",
- "hq_country_code": "string",
- "exchange_symbol": "string",
- "exact_size": "int32",
- "status_code": "string",
- "founded_year": "int32",
- "end_year": "int32",
- "tags": "string",
- "blog_url": "string",
- "blog_rss_url":"string",
- "hq_street1":"string",
- "hq_street2":"string",
- "hq_city":"string",
- "hq_state":"string",
- "hq_postal_code":"string",
- "region_code_1":"int32",
- "region_code_2":"int32",
- "hq_phone1":"string",
- "hq_phone2":"string",
- "hq_fax":"string",
- "changeset_id":"int32",
- "active":"boolean",
- "logo_media_id":"string",
- "txn":"int64"
- }
- </schema-info>
+ <schema-info>"string"</schema-info>
</value-serializer>
- </store>
- <store>
- <name>members</name>
- <persistence>read-only</persistence>
- <routing>client</routing>
- <replication-factor>1</replication-factor>
- <required-reads>1</required-reads>
- <required-writes>1</required-writes>
- <key-serializer>
- <type>json</type>
- <schema-info>"int32"</schema-info>
- </key-serializer>
- <value-serializer>
- <type>json</type>
- <schema-info>
- {
- "session_id": "int64",
- "member_id": "int32",
- "tracking_time": "int64",
- "page_seq": "int32",
- "page_key": "string",
- "tracking_info": "string",
- "bl_time": "int32",
- "total_time": "int32",
- "tracking_code": "string",
- "error_key": "string",
- "error_id": "int32",
- "browser_id": "string",
- "locale": "string"
- }
- </schema-info>
- </value-serializer>
- </store>
+ </store>
</stores>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
Binary file not shown.
Binary file not shown.
@@ -35,18 +35,18 @@
private static final Logger logger = Logger.getLogger(VoldemortClientShell.class.getName());
public static void main(String[] args) throws Exception {
- if (args.length < 2 || args.length > 3)
+ if(args.length < 2 || args.length > 3)
Utils.croak("USAGE: java VoldemortClientShell store_name bootstrap_url [command_file]");
String storeName = args[0];
String bootstrapUrl = args[1];
BufferedReader reader = null;
try {
- if (args.length == 3)
+ if(args.length == 3)
reader = new BufferedReader(new FileReader(args[2]));
else
reader = new BufferedReader(new InputStreamReader(System.in));
- } catch (IOException e) {
+ } catch(IOException e) {
Utils.croak("Failure to open input stream: " + e.getMessage());
}
@@ -60,32 +60,31 @@ public static void main(String[] args) throws Exception {
DefaultStoreClient<Object, Object> client = null;
try {
client = (DefaultStoreClient<Object, Object>) factory.getStoreClient(storeName);
- } catch (Exception e) {
+ } catch(Exception e) {
Utils.croak("Could not connect to server: " + e.getMessage());
}
System.out.println("Established connection to " + storeName + " via " + bootstrapUrl);
System.out.print(PROMPT);
- for (String line = reader.readLine(); line != null; line = reader.readLine()) {
- if (line.trim().equals(""))
+ for(String line = reader.readLine(); line != null; line = reader.readLine()) {
+ if(line.trim().equals(""))
continue;
try {
- if (line.toLowerCase().startsWith("put")) {
+ if(line.toLowerCase().startsWith("put")) {
JsonReader jsonReader = new JsonReader(new StringReader(line.substring("put".length())));
client.put(tightenNumericTypes(jsonReader.read()),
tightenNumericTypes(jsonReader.read()));
- } else if (line.toLowerCase().startsWith("get")) {
- logger.info ("get called:");
+ } else if(line.toLowerCase().startsWith("get")) {
JsonReader jsonReader = new JsonReader(new StringReader(line.substring("get".length())));
printVersioned(client.get(tightenNumericTypes(jsonReader.read())));
- } else if (line.toLowerCase().startsWith("delete")) {
+ } else if(line.toLowerCase().startsWith("delete")) {
JsonReader jsonReader = new JsonReader(new StringReader(line.substring("delete".length())));
client.delete(tightenNumericTypes(jsonReader.read()));
- } else if (line.startsWith("locate")) {
+ } else if(line.startsWith("locate")) {
JsonReader jsonReader = new JsonReader(new StringReader(line.substring("locate".length())));
Object key = tightenNumericTypes(jsonReader.read());
printNodeList(client.getResponsibleNodes(key));
- } else if (line.startsWith("help")) {
+ } else if(line.startsWith("help")) {
System.out.println("Commands:");
System.out.println("put key value -- Associate the given value with the key.");
System.out.println("get key -- Retrieve the value associated with the key.");
@@ -94,21 +93,21 @@ public static void main(String[] args) throws Exception {
System.out.println("help -- Print this message.");
System.out.println("exit -- Exit from this shell.");
System.out.println();
- } else if (line.startsWith("quit") || line.startsWith("exit")) {
+ } else if(line.startsWith("quit") || line.startsWith("exit")) {
System.out.println("k k thx bye.");
System.exit(0);
} else {
System.err.println("Invalid command.");
}
- } catch (SerializationException e) {
+ } catch(SerializationException e) {
System.err.print("Error serializing values: ");
System.err.println(e.getMessage());
- } catch (VoldemortException e) {
+ } catch(VoldemortException e) {
System.err.println("Exception thrown during operation.");
e.printStackTrace(System.err);
- } catch (ArrayIndexOutOfBoundsException e) {
+ } catch(ArrayIndexOutOfBoundsException e) {
System.err.println("Invalid command.");
- } catch (Exception e) {
+ } catch(Exception e) {
System.err.println("Unexpected error:");
e.printStackTrace(System.err);
}
@@ -117,8 +116,8 @@ public static void main(String[] args) throws Exception {
}
private static void printNodeList(List<Node> nodes) {
- if (nodes.size() > 0) {
- for (int i = 0; i < nodes.size(); i++) {
+ if(nodes.size() > 0) {
+ for(int i = 0; i < nodes.size(); i++) {
Node node = nodes.get(i);
System.out.println("Node " + node.getId());
System.out.println("host: " + node.getHost());
@@ -132,7 +131,7 @@ private static void printNodeList(List<Node> nodes) {
}
private static void printVersioned(Versioned<Object> v) {
- if (v == null) {
+ if(v == null) {
System.out.println("null");
} else {
System.out.print(v.getVersion());
@@ -144,27 +143,27 @@ private static void printVersioned(Versioned<Object> v) {
@SuppressWarnings("unchecked")
private static void printObject(Object o) {
- if (o == null) {
+ if(o == null) {
System.out.print("null");
- } else if (o instanceof String) {
+ } else if(o instanceof String) {
System.out.print('"');
System.out.print(o);
System.out.print('"');
- } else if (o instanceof Date) {
+ } else if(o instanceof Date) {
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
System.out.print("'");
System.out.print(df.format((Date) o));
System.out.print("'");
- } else if (o instanceof List) {
+ } else if(o instanceof List) {
List<Object> l = (List<Object>) o;
System.out.print("[");
- for (Object obj : l)
+ for(Object obj: l)
printObject(obj);
System.out.print("]");
- } else if (o instanceof Map) {
+ } else if(o instanceof Map) {
Map<String, Object> m = (Map<String, Object>) o;
System.out.print('{');
- for (String s : m.keySet()) {
+ for(String s: m.keySet()) {
printObject(s);
System.out.print(':');
printObject(m.get(s));
@@ -182,29 +181,29 @@ private static void printObject(Object o) {
*/
@SuppressWarnings("unchecked")
private static Object tightenNumericTypes(Object o) {
- if (o == null) {
+ if(o == null) {
return null;
- } else if (o instanceof List) {
+ } else if(o instanceof List) {
List l = (List) o;
- for (int i = 0; i < l.size(); i++)
+ for(int i = 0; i < l.size(); i++)
l.set(i, tightenNumericTypes(l.get(i)));
return l;
- } else if (o instanceof Map) {
+ } else if(o instanceof Map) {
Map m = (Map) o;
- for (Map.Entry entry : (Set<Map.Entry>) m.entrySet())
+ for(Map.Entry entry: (Set<Map.Entry>) m.entrySet())
m.put(entry.getKey(), tightenNumericTypes(entry.getValue()));
return m;
- } else if (o instanceof Number) {
+ } else if(o instanceof Number) {
Number n = (Number) o;
- if (o instanceof Integer) {
- if (n.intValue() < Byte.MAX_VALUE)
+ if(o instanceof Integer) {
+ if(n.intValue() < Byte.MAX_VALUE)
return n.byteValue();
- else if (n.intValue() < Short.MAX_VALUE)
+ else if(n.intValue() < Short.MAX_VALUE)
return n.shortValue();
else
return n;
- } else if (o instanceof Double) {
- if (n.doubleValue() < Float.MAX_VALUE)
+ } else if(o instanceof Double) {
+ if(n.doubleValue() < Float.MAX_VALUE)
return n.floatValue();
else
return n;
@@ -81,7 +81,7 @@ public AbstractStoreClientFactory(ExecutorService threadPool,
String storesXml = bootstrapMetadata(MetadataStore.STORES_KEY, bootstrapUrls);
List<StoreDefinition> storeDefs = storeMapper.readStoreList(new StringReader(storesXml));
StoreDefinition storeDef = null;
- for(StoreDefinition d : storeDefs)
+ for(StoreDefinition d: storeDefs)
if(d.getName().equals(storeName))
storeDef = d;
if(storeDef == null)
@@ -93,8 +93,7 @@ public AbstractStoreClientFactory(ExecutorService threadPool,
// construct mapping
Map<Integer, Store<byte[], byte[]>> clientMapping = Maps.newHashMap();
- for(Node node : cluster.getNodes()) {
- logger.info ("Adding node :" + node.getId() + " Store:" + storeDef.getName() + " host:" + node.getHost() + " port:" + getPort(node));
+ for(Node node: cluster.getNodes()) {
Store<byte[], byte[]> store = getStore(storeDef.getName(),
node.getHost(),
getPort(node));
@@ -139,7 +138,7 @@ public AbstractStoreClientFactory(ExecutorService threadPool,
}
private String bootstrapMetadata(String key, URI[] urls) {
- for(URI url : urls) {
+ for(URI url: urls) {
try {
Store<byte[], byte[]> remoteStore = getStore(MetadataStore.METADATA_STORE_NAME,
url.getHost(),
Oops, something went wrong.

0 comments on commit 9e864bc

Please sign in to comment.