http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/data/MapMessage.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/data/MapMessage.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/data/MapMessage.java deleted file mode 100644 index 6f59a55..0000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/data/MapMessage.java +++ /dev/null @@ -1,629 +0,0 @@ -package com.gemstone.gemfire.internal.tools.gfsh.app.cache.data; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintWriter; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import com.gemstone.gemfire.DataSerializer; - -/** - * HashMapMessage is a light weight message class for holding (name, value) paired - * data. It holds all primitive values and nested HashMapMessage objects. - * @author dpark - * - */ -public class MapMessage implements Mappable, Cloneable -{ - private static final long serialVersionUID = 1L; - - /** - * Used to dump messages. - */ - private final static StringBuffer spaces = new StringBuffer(" "); - - private HashMap map = new HashMap(); - - /** - * Creates an empty HashMapMessage object. - */ - public MapMessage() - { - } - - /** - * Puts a Mappable to the message. - * @param name The unique name identifying the value. - * @param mappable The value associated with the specified name. - */ - public void put(String name, Mappable mappable) - { - map.put(name, mappable); - } - - /** - * Puts a Listable to the message. - * @param name The unique name identifying the value. - * @param listable The value associated with the specified name. - */ - public void put(String name, Listable listable) - { - map.put(name, listable); - } - - /** - * Puts a String to the message. - * @param name The unique name identifying the value. - * @param value The value associated with the specified name. - */ - public void put(String name, String value) - { - map.put(name, value); - } - - /** - * Appends a boolean value to the message. - * @param name The unique name identifying the value. - * @param value The value associated with the specified name. - */ - public void put(String name, boolean value) - { - map.put(name, Boolean.valueOf(value)); - } - - /** - * Puts a byte value to the message. - * @param name The unique name identifying the value. - * @param value The value associated with the specified name. - */ - public void put(String name, byte value) - { - map.put(name, Byte.valueOf(value)); - } - - /** - * Appends a short value to the message. - * @param name The unique name identifying the value. - * @param value The value associated with the specified name. - */ - public void put(String name, short value) - { - map.put(name, Short.valueOf(value)); - } - - /** - * Puts a int value to the message. - * @param name The unique name identifying the value. - * @param value The value associated with the specified name. - */ - public void put(String name, int value) - { - map.put(name, Integer.valueOf(value)); - } - - /** - * Appends a long value to the message. - * @param name The unique name identifying the value. - * @param value The value associated with the specified name. - */ - public void put(String name, long value) - { - map.put(name, Long.valueOf(value)); - } - - /** - * Puts a float value to the message. - * @param name The unique name identifying the value. - * @param value The value associated with the specified name. - */ - public void put(String name, float value) - { - map.put(name, new Float(value)); - } - - /** - * Puts a double value to the message. - ** @param name The unique name identifying the value. - * @param value The value associated with the specified name. - */ - public void put(String name, double value) - { - map.put(name, new Double(value)); - } - - /** - * Returns the object identified by the specified name found - * in the message. - */ - public Object getValue(String name) - { - return map.get(name); - } - - /** - * Returns the boolean value identified by the specified name found - * in the message. - * @param name The unique name identifying the value. - * @throws NoSuchFieldException Thrown if the mapping value is not found. - * @throws InvalidTypeException Thrown if the value type is different. - */ - public boolean getBoolean(String name) throws NoSuchFieldException, InvalidTypeException - { - Object value = map.get(name); - if (value == null) { - throw new NoSuchFieldException("The field " + name + " is not found."); - } else { - if (value instanceof Boolean) { - return ((Boolean)value).booleanValue(); - } else { - throw new InvalidTypeException("The field " + name + " has the type " + value.getClass().getName()); - } - } - } - - public byte getByte(String name) throws NoSuchFieldException, InvalidTypeException - { - Object value = map.get(name); - if (value == null) { - throw new NoSuchFieldException("The field " + name + " is not found."); - } else { - if (value instanceof Byte) { - return ((Byte)value).byteValue(); - } else { - throw new InvalidTypeException("The field " + name + " has the type " + value.getClass().getName()); - } - } - } - - /** - * Returns the char value identified by the specified name found - * in the message. - * @param name The unique name identifying the value. - * @throws NoSuchFieldException Thrown if the mapping value is not found. - * @throws InvalidTypeException Thrown if the value type is different. - */ - public char getChar(String name) throws NoSuchFieldException, InvalidTypeException - { - Object value = map.get(name); - if (value == null) { - throw new NoSuchFieldException("The field " + name + " is not found."); - } else { - if (value instanceof Character) { - return ((Character)value).charValue(); - } else { - throw new InvalidTypeException("The field " + name + " has the type " + value.getClass().getName()); - } - } - } - - /** - * Returns the short value identified by the specified name found - * in the message. - * @param name The unique name identifying the value. - * @throws NoSuchFieldException Thrown if the mapping value is not found. - * @throws InvalidTypeException Thrown if the value type is different. - */ - public short getShort(String name) throws NoSuchFieldException, InvalidTypeException - { - Object value = map.get(name); - if (value == null) { - throw new NoSuchFieldException("The field " + name + " is not found."); - } else { - if (value instanceof Short) { - return ((Short)value).shortValue(); - } else { - throw new InvalidTypeException("The field " + name + " has the type " + value.getClass().getName()); - } - } - } - - /** - * Returns the int value identified by the specified name found - * in the message. - * @param name The unique name identifying the value. - * @throws NoSuchFieldException Thrown if the mapping value is not found. - * @throws InvalidTypeException Thrown if the value type is different. - */ - public int getInt(String name) throws NoSuchFieldException, InvalidTypeException - { - Object value = map.get(name); - if (value == null) { - throw new NoSuchFieldException("The field " + name + " is not found."); - } else { - if (value instanceof Integer) { - return ((Integer)value).intValue(); - } else { - throw new InvalidTypeException("The field " + name + " has the type " + value.getClass().getName()); - } - } - } - - /** - * Returns the long value identified by the specified name found - * in the message. - * @param name The unique name identifying the value. - * @throws NoSuchFieldException Thrown if the mapping value is not found. - * @throws InvalidTypeException Thrown if the value type is different. - */ - public long getLong(String name) throws NoSuchFieldException, InvalidTypeException - { - Object value = map.get(name); - if (value == null) { - throw new NoSuchFieldException("The field " + name + " is not found."); - } else { - if (value instanceof Long) { - return ((Long)value).longValue(); - } else { - throw new InvalidTypeException("The field " + name + " has the type " + value.getClass().getName()); - } - } - } - - /** - * Returns the float value identified by the specified name found - * in the message. - * @param name The unique name identifying the value. - * @throws NoSuchFieldException Thrown if the mapping value is not found. - * @throws InvalidTypeException Thrown if the value type is different. - */ - public float getFloat(String name) throws NoSuchFieldException, InvalidTypeException - { - Object value = map.get(name); - if (value == null) { - throw new NoSuchFieldException("The field " + name + " is not found."); - } else { - if (value instanceof Float) { - return ((Float)value).floatValue(); - } else { - throw new InvalidTypeException("The field " + name + " has the type " + value.getClass().getName()); - } - } - } - - /** - * Returns the double value identified by the specified name found - * in the message. - * @param name The unique name identifying the value. - * @throws NoSuchFieldException Thrown if the mapping value is not found. - * @throws InvalidTypeException Thrown if the value type is different. - */ - public double getDouble(String name) throws NoSuchFieldException, InvalidTypeException - { - Object value = map.get(name); - if (value == null) { - throw new NoSuchFieldException("The field " + name + " is not found."); - } else { - if (value instanceof Double) { - return ((Double)value).doubleValue(); - } else { - throw new InvalidTypeException("The field " + name + " has the type " + value.getClass().getName()); - } - } - } - - /** - * Returns the String value identified by the specified name found - * in the message. - * @param name The unique name identifying the value. - * @throws NoSuchFieldException Thrown if the mapping value is not found. - * @throws InvalidTypeException Thrown if the value type is different. - */ - public String getString(String name) throws NoSuchFieldException, InvalidTypeException - { - Object value = map.get(name); - if (value == null) { - throw new NoSuchFieldException("The field " + name + " is not found."); - } else { - if (value instanceof String) { - return (String)value; - } else { - throw new InvalidTypeException("The field " + name + " has the type " + value.getClass().getName()); - } - } - } - - /** - * Returns true if the message contains nested Mappable. - */ - public boolean hasMappable() - { - Map.Entry entries[] = getAllEntries(); - for (int i = 0; i < entries.length; i++) { - if (entries[i].getValue() instanceof Mappable) { - return true; - } - } - return false; - } - - /** - * Returns true if the message contains nested Listable. - */ - public boolean hasListable() - { - Map.Entry entries[] = getAllEntries(); - for (int i = 0; i < entries.length; i++) { - if (entries[i].getValue() instanceof Listable) { - return true; - } - } - return false; - } - - /** - * Removes the specified entry from the message. - */ - public Object remove(String name) - { - return map.remove(name); - } - - /** - * Returns the number of entries in this message. - */ - public int size() - { - return map.size(); - } - - public Collection values() - { - return map.values(); - } - - public Collection getValues() - { - return map.values(); - } - - public Set keys() - { - return map.keySet(); - } - - public Set getKeys() - { - return map.keySet(); - } - - public Set getEntries() - { - return map.entrySet(); - } - - /** - * Returns all of the entries in the form of array. - */ - public Map.Entry[] getAllEntries() - { - return (Map.Entry[])map.entrySet().toArray(new Map.Entry[0]); - } - - /** - * Returns all of the primitive entries in the message. - */ - public Map.Entry[] getAllPrimitives() - { - Map.Entry entries[] = getAllEntries(); - Map.Entry messages[] = new Map.Entry[entries.length]; - int count = 0; - for (int i = 0; i < entries.length; i++) { - if (entries[i].getValue() instanceof Mappable == false) { - messages[count++] = entries[i]; - } - } - Map.Entry m[] = new Map.Entry[count]; - System.arraycopy(messages, 0, m, 0, count); - return m; - } - - /** - * Returns the number primitive entries in this message. - */ - public int getPrimitiveCount() - { - Map.Entry entries[] = getAllEntries(); - int count = 0; - for (int i = 0; i < entries.length; i++) { - if (entries[i].getValue() instanceof Mappable == false) { - count++; - } - } - return count; - } - - /** - * Returns all of the entries that have the Mappable type, i.e., nested - * messages. - */ - public Map.Entry[] getAllMappables() - { - Map.Entry entries[] = getAllEntries(); - Map.Entry messages[] = new Map.Entry[entries.length]; - int count = 0; - for (int i = 0; i < entries.length; i++) { - if (entries[i].getValue() instanceof Mappable) { - messages[count++] = entries[i]; - } - } - Map.Entry m[] = new Map.Entry[count]; - System.arraycopy(messages, 0, m, 0, count); - return m; - } - - /** - * Returns all of the entries that have the Listable type, i.e., nested - * messages. - */ - public Map.Entry[] getAllListables() - { - Map.Entry entries[] = getAllEntries(); - Map.Entry messages[] = new Map.Entry[entries.length]; - int count = 0; - for (int i = 0; i < entries.length; i++) { - if (entries[i].getValue() instanceof Listable) { - messages[count++] = entries[i]; - } - } - Map.Entry m[] = new Map.Entry[count]; - System.arraycopy(messages, 0, m, 0, count); - return m; - } - - /** - * Returns the number of Mappable entries in this message. - */ - public int getMappableCount() - { - Map.Entry entries[] = getAllEntries(); - int count = 0; - for (int i = 0; i < entries.length; i++) { - if (entries[i].getValue() instanceof Mappable) { - count++; - } - } - return count; - } - - /** - * Returns the number of Listable entries in this message. - */ - public int getListableCount() - { - Map.Entry entries[] = getAllEntries(); - int count = 0; - for (int i = 0; i < entries.length; i++) { - if (entries[i].getValue() instanceof Listable) { - count++; - } - } - return count; - } - - /** - * Clears the message. It removes all of the entries in the message. - * - */ - public void clear() - { - map.clear(); - } - - private void convertToString(StringBuffer buffer, Mappable message, int level) - { - Map.Entry entries[] = message.getAllEntries(); - for (int i = 0; i < entries.length; i++) { - if (entries[i].getValue() instanceof Mappable) { - buffer.append(spaces.substring(0, level*3) + entries[i].getKey() + "*****" + "\n"); - convertToString(buffer, (Mappable)entries[i].getValue(), level+1); - } else { - buffer.append(spaces.substring(0, level*3)+ entries[i].getKey() + " = " + entries[i].getValue() + "\n"); - } - } - } - -// public void convertToString(StringBuffer buffer) -// { -// if (buffer == null) { -// return; -// } -// convertToString(buffer); -// } - - public String toString() - { - StringBuffer buffer = new StringBuffer(100); - convertToString(buffer, this, 0); - return buffer.toString(); - } - - /** - * Recursively dumps the message contents to the specified writer. - */ - private void dump(PrintWriter writer, Mappable message, int level) - { - Map.Entry entries[] = message.getAllEntries(); - for (int i = 0; i < entries.length; i++) { - if (entries[i].getValue() instanceof Mappable) { - writer.println(spaces.substring(0, level*3) + entries[i].getKey() + "*****"); - dump(writer, (Mappable)entries[i].getValue(), level+1); - } else if (entries[i].getValue() instanceof Listable) { - writer.println(spaces.substring(0, level*3) + entries[i].getKey() + "*****"); - dump(writer, (Listable)entries[i].getValue(), level+1); - } else { - writer.println(spaces.substring(0, level*3)+ entries[i].getKey() + " = " + entries[i].getValue()); - } - } - } - - /** - * Recursively dumps the message contents to the specified writer. - */ - private void dump(PrintWriter writer, Listable message, int level) - { - Object values[] = message.getAllValues(); - for (int i = 0; i < values.length; i++) { - if (values[i] instanceof Listable) { - writer.println(spaces.substring(0, level*3) + values[i] + "*****"); - dump(writer, (Listable)values[i], level+1); - } if (values[i] instanceof Listable) { - writer.println(spaces.substring(0, level*3) + values[i] + "*****"); - dump(writer, (Mappable)values[i], level+1); - } else { - writer.println(spaces.substring(0, level*3)+ values[i]); - } - } - } - - /** - * Dumps the message contents to the specified output stream. - * @param out The outputstream to which the contents are dumped. - */ - public void dump(OutputStream out) - { - if (out == null) { - return; - } - PrintWriter writer = new PrintWriter(out); - dump(writer, this, 0); - writer.flush(); - } - - /** - * Dumps the message contents to the standard output stream (System.out). - */ - public void dump() - { - PrintWriter writer = new PrintWriter(System.out); - dump(writer, this, 0); - writer.flush(); - } - - /** - * Returns a shallow copy of this <tt>HashMapMessage</tt> instance. (The - * elements themselves are not copied.) - * - * @return a clone of this <tt>HashMapMessage</tt> instance. - */ - public Object clone() - { - MapMessage dup = new MapMessage(); - dup.map = (HashMap)this.map.clone(); - return dup; - } - - public void fromData(DataInput dataInput) throws IOException, ClassNotFoundException - { - map = DataSerializer.readHashMap(dataInput); - } - - public void toData(DataOutput dataOutput) throws IOException - { - DataSerializer.writeHashMap(map, dataOutput); - } -} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/data/Mappable.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/data/Mappable.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/data/Mappable.java deleted file mode 100644 index 08d475a..0000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/data/Mappable.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.gemstone.gemfire.internal.tools.gfsh.app.cache.data; - -import java.io.OutputStream; -import java.util.Collection; -import java.util.Map; -import java.util.Set; - -import com.gemstone.gemfire.DataSerializable; - -public interface Mappable extends DataSerializable -{ - public void put(String key, Mappable mappable); - public void put(String key, Listable listable); - public void put(String key, String value); - public void put(String key, boolean value); - public void put(String key, byte value); - public void put(String key, short value); - public void put(String key, int value); - public void put(String key, long value); - public void put(String key, float value); - public void put(String key, double value); - public Object getValue(String key); - public boolean getBoolean(String key) throws NoSuchFieldException, InvalidTypeException; - public byte getByte(String name) throws NoSuchFieldException, InvalidTypeException; - public char getChar(String key) throws NoSuchFieldException, InvalidTypeException; - public short getShort(String key) throws NoSuchFieldException, InvalidTypeException; - public int getInt(String key) throws NoSuchFieldException, InvalidTypeException; - public long getLong(String key) throws NoSuchFieldException, InvalidTypeException; - public float getFloat(String key) throws NoSuchFieldException, InvalidTypeException; - public double getDouble(String key) throws NoSuchFieldException, InvalidTypeException; - public String getString(String key) throws NoSuchFieldException, InvalidTypeException; - public boolean hasMappable(); - public boolean hasListable(); - public Object remove(String key); - public int size(); - public Collection getValues(); - public Set getKeys(); - public Set getEntries(); - public Map.Entry[] getAllEntries(); - public Map.Entry[] getAllPrimitives(); - public int getPrimitiveCount(); - public Map.Entry[] getAllMappables(); - public Map.Entry[] getAllListables(); - public int getMappableCount(); - public int getListableCount(); - public void clear(); - public void dump(OutputStream out); - public Object clone(); - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/EntryMap.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/EntryMap.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/EntryMap.java deleted file mode 100644 index ccc5f57..0000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/EntryMap.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.gemstone.gemfire.internal.tools.gfsh.app.cache.index; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import com.gemstone.gemfire.DataSerializable; -import com.gemstone.gemfire.DataSerializer; -import com.gemstone.gemfire.internal.cache.CachedDeserializable; - -public class EntryMap extends HashMap<DataSerializable, Object> implements DataSerializable -{ - private boolean keysOnly = false; - - public EntryMap() - { - super(); - } - - public EntryMap(int size) - { - super(size); - } - - public EntryMap(int size, float loadfactor) - { - this(size, loadfactor, false); - } - - public EntryMap(int size, float loadfactor, boolean keysOnly) - { - super(size, loadfactor); - this.keysOnly = keysOnly; - } - - public void fromData(DataInput in) throws IOException, - ClassNotFoundException - { - keysOnly = in.readBoolean(); - int size = in.readInt(); - - if (keysOnly) { - - for(int i=0;i<size;i++) - { - DataSerializable key = (DataSerializable) DataSerializer.readObject(in); - put(key, key); - } - - } else { - for(int i=0;i<size;i++) - { - DataSerializable key = (DataSerializable) DataSerializer.readObject(in); - // This will be deserialized by Java client and this will never be used in the server... - // We can de-serialize the value object to it's base class, rather than - // to a byte array. - DataSerializable value = (DataSerializable) DataSerializer.readObject(in); - put(key, value); - } - } - } - - public void toData(DataOutput out) throws IOException - { - out.writeBoolean(keysOnly); - out.writeInt(size()); - if (keysOnly) { - for (Map.Entry<DataSerializable, Object> e : entrySet()) { - DataSerializer.writeObject(e.getKey(), out); - } - } else { - for (Map.Entry<DataSerializable, Object> e : entrySet()) { - DataSerializer.writeObject(e.getKey(), out); - out.write(((CachedDeserializable) e.getValue()).getSerializedValue()); - } - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/IndexInfo.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/IndexInfo.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/IndexInfo.java deleted file mode 100644 index aaac9ef..0000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/IndexInfo.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.gemstone.gemfire.internal.tools.gfsh.app.cache.index; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - -import com.gemstone.gemfire.DataSerializable; -import com.gemstone.gemfire.DataSerializer; -import com.gemstone.gemfire.internal.tools.gfsh.app.misc.util.ReflectionUtil; - - -public class IndexInfo implements DataSerializable -{ - private static final long serialVersionUID = 1L; - - public int indexListSize; - - public int indexMapSize; - - public Object minSetQueryKey; - public Object maxSetQueryKey; - - public int minSetSize = Integer.MAX_VALUE; - public int maxSetSize = 0; - - public String toString() - { - return ReflectionUtil.toStringPublicMembers(this); - } - - public void fromData(DataInput in) throws IOException, - ClassNotFoundException - { - indexListSize = in.readInt(); - indexMapSize = in.readInt(); - minSetSize = in.readInt(); - maxSetSize = in.readInt(); - minSetQueryKey = DataSerializer.readObject(in); - maxSetQueryKey = DataSerializer.readObject(in); - } - - public void toData(DataOutput out) throws IOException - { - out.writeInt(indexListSize); - out.writeInt(indexMapSize); - out.writeInt(minSetSize); - out.writeInt(maxSetSize); - DataSerializer.writeObject(minSetQueryKey, out); - DataSerializer.writeObject(maxSetQueryKey, out); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/Indexer.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/Indexer.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/Indexer.java deleted file mode 100644 index e75700d..0000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/Indexer.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.gemstone.gemfire.internal.tools.gfsh.app.cache.index; - -import java.util.Map; - - -public interface Indexer -{ - public Map query(Object queryKey); - - public int size(Object queryKey); - - public IndexInfo getIndexInfo(); -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/IndexerManager.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/IndexerManager.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/IndexerManager.java deleted file mode 100644 index a15f7ce..0000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/IndexerManager.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.gemstone.gemfire.internal.tools.gfsh.app.cache.index; - -import java.util.HashMap; - - -public class IndexerManager -{ - private static final IndexerManager indexerManager = new IndexerManager(); - - private HashMap<String, Indexer> indexerMap = new HashMap(); - - public static IndexerManager getIndexerManager() - { - return indexerManager; - } - - private IndexerManager() - { -// indexerManager = this; - } - - void putIndxer(String regionPath, Indexer indexer) - { - indexerMap.put(regionPath, indexer); - } - - public Indexer getIndexer(String regionPath) - { - return indexerMap.get(regionPath); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/LookupService.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/LookupService.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/LookupService.java deleted file mode 100644 index 5e15b26..0000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/LookupService.java +++ /dev/null @@ -1,352 +0,0 @@ -package com.gemstone.gemfire.internal.tools.gfsh.app.cache.index; - -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.gemstone.gemfire.cache.CacheFactory; -import com.gemstone.gemfire.internal.util.BlobHelper; -import com.gemstone.gemfire.internal.tools.gfsh.app.cache.index.task.IndexInfoTask; -import com.gemstone.gemfire.internal.tools.gfsh.app.cache.index.task.QuerySizeTask; -import com.gemstone.gemfire.internal.tools.gfsh.app.cache.index.task.QueryTask; -import com.gemstone.gemfire.internal.tools.gfsh.app.command.CommandClient; -import com.gemstone.gemfire.internal.tools.gfsh.command.CommandResults; - -/** - * LookupService provides custom query access to GemFire cache. It supports - * equality and "AND" conditions only. The server must install - * com.gemstone.gemfire.internal.tools.gfsh.cache.index.Indexer before LookupService can - * be used. The gfcommand addon library includes the sample implementation - * com.gemstone.gemfire.tools.gfsh.cache.index.IndexBuilder which is for demo - * purposes only as it lacks HA and recovery support. - * @author dpark - */ -public class LookupService -{ - CommandClient commandClient; - - public LookupService(String poolNameOrEndpoints) - { - this(null, poolNameOrEndpoints); - } - - /** - * Constructs a new LookupService object. - * @param commandRegionPath The command region full path. This region is - * used to send query commands to the cache. If - * null, the default "/__command" region is used. - * @param poolNameOrEndpoints A pool name or comma separated list of GemFire cache servers. - * The endpoints format is "e1=host:port,e2=host2:port". - * If the name is not in the endpoints format then it is treated - * as a pool name. - * @exception Throws a LookupServiceException if it encounters an error from the - * underlying GemFire communications mechanism. - */ - public LookupService(String commandRegionPath, String poolNameOrEndpoints) - { - try { - commandClient = new CommandClient(commandRegionPath, poolNameOrEndpoints); - } catch (Exception ex) { - throw new LookupServiceException("Unable to create LookupService due to a cache exception: " + ex.getMessage(), ex); - } - } - - /** - * Constructs a new LookupService object with the specified command client - * object. - * @param commandClient The command client object. - */ - public LookupService(CommandClient commandClient) - { - this.commandClient = commandClient; - } - - /** - * Returns the command region path. It returns null, if the command - * client is not defined. - */ - public String getCommandRegionPath() - { - if (commandClient == null) { - return null; - } - return commandClient.getOutboxRegionFullPath(); - } - - /** - * Returns the endpoints. It returns null if a pool is in use. - */ - public String getEndpoints() - { - if (commandClient == null) { - return null; - } - return commandClient.getEndpoints(); - } - - /** - * Returns the pool name. It returns null if endpoints are used. - */ - public String getPoolName() - { - if (commandClient == null) { - return null; - } - return commandClient.getPoolName(); - } - - /** - * Returns the query results in the form of Map. The returned - * Map contains the specified region (key, value) pairs. - * - * @param regionPath The full path of a region to query. Note that this region path is - * not the same as the command region path specified in the LookupService constructor. This - * region contains data that the query is to be executed. The LookupService constructor's - * region path is used for sending the query command. - * - * @param queryKey The query key object that contains the fields to search. - * @return Returns the query results in the form of Map. The returned - * Map contains the specified region (key, value) pairs. - * @exception Throws a LookupServiceException if it encounters an error from the - * underlying GemFire communications mechanism. - */ - public Map entryMap(String regionPath, Object queryKey) - { - try { - CommandResults results = commandClient.execute(new QueryTask(regionPath, queryKey, QueryTask.TYPE_KEYS_VALUES)); - Map resultMap = null; - switch (results.getCode()) { - case QueryTask.SUCCESS_RR: - { - byte[] blob = (byte[])results.getDataObject(); - if (blob != null) { - resultMap = (Map)BlobHelper.deserializeBlob(blob); - } - } - break; - - case QueryTask.SUCCESS_PR: - { - List list = (List)results.getDataObject(); - try { - Iterator<byte[]> iterator = list.iterator(); - while (iterator.hasNext()) { - byte[] blob = iterator.next(); - if (blob != null) { - Map map = (Map)BlobHelper.deserializeBlob(blob); - if (resultMap == null) { - resultMap = map; - } else { - resultMap.putAll(map); - } - } - } - } catch (Exception ex) { - CacheFactory.getAnyInstance().getLogger().warning("Error occurred while deserializing to blob: " + ex.getMessage(), ex); - } - } - break; - } - - return resultMap; - } catch (Exception ex) { - throw new LookupServiceException("Unable to retrieve the entry map due to a cache exception: " + ex.getMessage(), ex); - } - } - - /** - * Returns the query results in the form of Set. The returned - * Set contains the specified region keys. - * @param regionPath The full path of a region to query. Note that this region path is - * not the same as the command region path specified in the LookupService constructor. This - * region contains data that the query is to be executed. The LookupService constructor's - * region path is used for sending the query command. - * @param queryKey The query key object that contains the fields to search. - * @return Returns the query results in the form of Set. The returned - * Set contains the specified region keys. - */ - public Set keySet(String regionPath, Object queryKey) - { - try { - CommandResults results = commandClient.execute(new QueryTask(regionPath, queryKey, QueryTask.TYPE_KEYS)); - Set keys = null; - switch (results.getCode()) - { - case QueryTask.SUCCESS_RR: - { - byte[] blob = (byte[]) results.getDataObject(); - - if (blob != null) { - keys = (Set) BlobHelper.deserializeBlob(blob); - } - } - break; - - case QueryTask.SUCCESS_PR: - { - try { - List list = (List)results.getDataObject(); - Iterator<byte[]> iterator = list.iterator(); - while (iterator.hasNext()) { - byte[] blob = iterator.next(); - if (blob != null) { - Set set = (Set)BlobHelper.deserializeBlob(blob); - if (keys == null) { - keys = set; - } else { - keys.addAll(set); - } - } - } - } catch (Exception ex) { - CacheFactory.getAnyInstance().getLogger().warning("Error occurred while deserializing to blob: " + ex.getMessage(), ex); - } - } - break; - } - return keys; - } catch (Exception ex) { - throw new LookupServiceException("Unable to retrieve the key set due to a cache exception: " + ex.getMessage(), ex); - } - } - - /** - * Returns the query results in the form of Collection. The returned - * Collection contains the specified region values. - * @param regionPath The full path of a region to query. Note that this region path is - * not the same as the command region path specified in the LookupService constructor. This - * region contains data that the query is to be executed. The LookupService constructor's - * region path is used for sending the query command. - * @param queryKey The query key object that contains the fields to search. - * @return Returns the query results in the form of Collection. The returned - * Collection contains the specified region values. - */ - public Collection values(String regionPath, Object queryKey) - { - try { - CommandResults results = commandClient.execute(new QueryTask(regionPath, queryKey, QueryTask.TYPE_VALUES)); - Collection values = null; - switch (results.getCode()) - { - case QueryTask.SUCCESS_RR: - { - byte[] blob = (byte[]) results.getDataObject(); - - if (blob != null) { - values = (Collection) BlobHelper.deserializeBlob(blob); - } - } - break; - - case QueryTask.SUCCESS_PR: - { - try { - List list = (List)results.getDataObject(); - Iterator<byte[]> iterator = list.iterator(); - while (iterator.hasNext()) { - byte[] blob = iterator.next(); - if (blob != null) { - Collection col = (Collection)BlobHelper.deserializeBlob(blob); - if (values == null) { - values = col; - } else { - values.addAll(col); - } - } - } - } catch (Exception ex) { - CacheFactory.getAnyInstance().getLogger().warning("Error occurred while deserializing to blob: " + ex.getMessage(), ex); - } - } - break; - } - return values; - } catch (Exception ex) { - throw new LookupServiceException("Unable to retrieve the values to a cache exception: " + ex.getMessage(), ex); - } - } - - /** - * Returns the IndexInfo that contains the cache indexer information. - * - * @param regionPath The full path of a region to query. - * @return Returns the IndexInfo that contains the cache indexer information. - * @exception Throws a LookupServiceException if it encounters an error from the - * underlying GemFire communications mechanism. - */ - public IndexInfo[] getIndexInfoArray(String regionPath) - { - try { - IndexInfo[] indexInfoArray = null; - CommandResults results = commandClient.execute(new IndexInfoTask(regionPath)); - switch (results.getCode()) { - case QueryTask.SUCCESS_RR: - { - IndexInfo indexInfo = (IndexInfo)results.getDataObject(); - if (indexInfo != null) { - indexInfoArray = new IndexInfo[] { indexInfo }; - } - } - break; - - case QueryTask.SUCCESS_PR: - { - List list = (List)results.getDataObject(); - if (list != null) { - indexInfoArray = (IndexInfo[])list.toArray(new IndexInfo[0]); - } - } - break; - } - return indexInfoArray; - - } catch (Exception ex) { - throw new LookupServiceException("Unable to retrieve index info due to a cache exception: " + ex.getMessage(), ex); - } - } - - /** - * Returns the size of the query results. - * - * @param regionPath The full path of a region to query. - * @param queryKey The query key object that contains the fields to search. - - * @return Returns the size of the query results. - * @exception Throws a LookupServiceException if it encounters an error from the - * underlying GemFire communications mechanism. - */ - public int size(String regionPath, Object queryKey) - { - try { - CommandResults results = commandClient.execute(new QuerySizeTask(regionPath, queryKey)); - return (Integer)results.getDataObject(); - } - catch (Exception ex) - { - throw new LookupServiceException("Unable to retrieve the size due to a cache exception: " + ex.getMessage(), ex); - } - } - - /** - * Closes the LookupService. Note that if there is another instance of LookupService that - * was created with the same constructor arguments, i.e., commandRegionPath and endpoints, - * that instance will also be closed. Invoking this method more than once will throw - * a LookupServiceException. - * - * @exception Throws a LookupServiceException if it encounters an error from the - * underlying GemFire communications mechanism. - */ - public void close() - { - try - { - commandClient.close(); - } - catch (Exception ex) - { - throw new LookupServiceException("Exception raised while closing LookupService: " + ex.getMessage(), ex); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/LookupServiceException.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/LookupServiceException.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/LookupServiceException.java deleted file mode 100644 index e924230..0000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/LookupServiceException.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.gemstone.gemfire.internal.tools.gfsh.app.cache.index; - -/** - * LookupService throws LookupServiceException if it encounters - * an error from the underlying GemFire communications mechanism. - */ -class LookupServiceException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - /** - * Constructs a new LookupServiceException. - */ - LookupServiceException() - { - super(); - } - - /** - * Constructs a new LookupServiceException exception with the specified detail message. - * - * @param message the detail message (which is saved for later retrieval - * by the {@link #getMessage()} method). - */ - public LookupServiceException(String message) - { - super(message, null); - } - - /** - * Constructs a new LookupServiceException exception with the specified detail message and - * cause. - * <p>Note that the detail message associated with - * <code>cause</code> is <i>not</i> automatically incorporated in - * this exception's detail message. - * - * @param message the detail message (which is saved for later retrieval - * by the {@link #getMessage()} method). - * @param cause the cause (which is saved for later retrieval by the - * {@link #getCause()} method). (A <tt>null</tt> value is - * permitted, and indicates that the cause is nonexistent or - * unknown.) - */ - public LookupServiceException(String message, Throwable cause) - { - super(message, cause); - } - - /** - * Constructs a new LookupServiceException exception with the specified cause. - * <p>Note that the detail message associated with - * <code>cause</code> is <i>not</i> automatically incorporated in - * this exception's detail message. - * - * @param cause the cause (which is saved for later retrieval by the - * {@link #getCause()} method). (A <tt>null</tt> value is - * permitted, and indicates that the cause is nonexistent or - * unknown.) - */ - public LookupServiceException(Throwable cause) - { - super(cause); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/task/ForceGCTask.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/task/ForceGCTask.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/task/ForceGCTask.java deleted file mode 100644 index 2ecd3c9..0000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/task/ForceGCTask.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.gemstone.gemfire.internal.tools.gfsh.app.cache.index.task; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - -import com.gemstone.gemfire.internal.tools.gfsh.command.CommandResults; -import com.gemstone.gemfire.internal.tools.gfsh.command.CommandTask; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - -public class ForceGCTask implements CommandTask -{ - private static final long serialVersionUID = 1L; - - public ForceGCTask() {} - - @SuppressFBWarnings(value="DM_GC",justification="This is the desired functionality") - public CommandResults runTask(Object userData) - { - Runtime.getRuntime().gc(); - return new CommandResults(); - } - - public void fromData(DataInput in) throws IOException, - ClassNotFoundException - { - } - - public void toData(DataOutput out) throws IOException - { - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/task/IndexInfoTask.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/task/IndexInfoTask.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/task/IndexInfoTask.java deleted file mode 100644 index f0e7d80..0000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/task/IndexInfoTask.java +++ /dev/null @@ -1,131 +0,0 @@ -package com.gemstone.gemfire.internal.tools.gfsh.app.cache.index.task; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import com.gemstone.gemfire.cache.Cache; -import com.gemstone.gemfire.cache.CacheFactory; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.execute.FunctionContext; -import com.gemstone.gemfire.internal.cache.PartitionedRegion; -import com.gemstone.gemfire.internal.tools.gfsh.aggregator.AggregateFunction; -import com.gemstone.gemfire.internal.tools.gfsh.aggregator.AggregateResults; -import com.gemstone.gemfire.internal.tools.gfsh.app.aggregator.AggregatorException; -import com.gemstone.gemfire.internal.tools.gfsh.app.aggregator.AggregatorPeer; -import com.gemstone.gemfire.internal.tools.gfsh.app.cache.index.IndexInfo; -import com.gemstone.gemfire.internal.tools.gfsh.app.cache.index.Indexer; -import com.gemstone.gemfire.internal.tools.gfsh.app.cache.index.IndexerManager; -import com.gemstone.gemfire.internal.tools.gfsh.app.misc.util.DataSerializerEx; -import com.gemstone.gemfire.internal.tools.gfsh.command.CommandResults; -import com.gemstone.gemfire.internal.tools.gfsh.command.CommandTask; - -public class IndexInfoTask implements CommandTask, AggregateFunction -{ - private static final long serialVersionUID = 1L; - - private transient volatile boolean aggregationExecuted = false; - private final Object aggregationExecutedLock = new Object(); - - private String regionPath; - - public IndexInfoTask() {} - - public IndexInfoTask(String regionPath) - { - this.regionPath = regionPath; - } - - public CommandResults runTask(Object userData) - { - Cache cache = CacheFactory.getAnyInstance(); - cache.getLogger().fine("IndexInfoTask.runTask(): regionPath = " + regionPath); - - CommandResults results = new CommandResults(); - - Region region = cache.getRegion(regionPath); - if (region == null) { - results.setCode(QueryTask.ERROR_REGION_UNDEFINED); - results.setCodeMessage("The specified region " + regionPath + " is undefined."); - return results; - } - - if (region instanceof PartitionedRegion) { - - // Partitioned Region - AggregatorPeer aggregator = new AggregatorPeer((PartitionedRegion)region); - try { - Object obj = aggregator.aggregate(this); - results.setCode(QueryTask.SUCCESS_PR); - results.setDataObject(obj); - } catch (AggregatorException ex) { - results.setCode(QueryTask.ERROR_AGGREGATOR); - results.setCodeMessage("Unabled to create aggregator: " + ex.getMessage()); - ex.printStackTrace(); - } - - } else { - - // Replicated Region - results.setCode(QueryTask.SUCCESS_RR); - results.setDataObject(getIndexInfo()); - - } - - return results; - } - - public AggregateResults run(FunctionContext context) - { - AggregateResults results = null; - synchronized (aggregationExecutedLock) { - if (aggregationExecuted == false) { - results = new AggregateResults(); - results.setDataObject(getIndexInfo()); - aggregationExecuted = true; - } - } - return results; - } - - public Object aggregate(List list) - { - ArrayList<IndexInfo> aggregateList = null; - for (Iterator<AggregateResults> iterator = list.iterator(); iterator.hasNext();) { - AggregateResults results = iterator.next(); - if (results != null) { - if (aggregateList == null) { - aggregateList = new ArrayList(list.size()); - } - aggregateList.add((IndexInfo)results.getDataObject()); - } - } - return aggregateList; - } - - public Object aggregateDistributedSystems(Object[] results) - { - return null; - } - - private IndexInfo getIndexInfo() - { - Indexer indexer = IndexerManager.getIndexerManager().getIndexer(regionPath); - return indexer.getIndexInfo(); - } - - public void fromData(DataInput in) throws IOException, - ClassNotFoundException - { - regionPath = (String) DataSerializerEx.readUTF(in); - } - - public void toData(DataOutput out) throws IOException - { - DataSerializerEx.writeUTF(regionPath, out); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/task/QuerySizeTask.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/task/QuerySizeTask.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/task/QuerySizeTask.java deleted file mode 100644 index 0d9bee0..0000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/task/QuerySizeTask.java +++ /dev/null @@ -1,134 +0,0 @@ -package com.gemstone.gemfire.internal.tools.gfsh.app.cache.index.task; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.util.Iterator; -import java.util.List; - -import com.gemstone.gemfire.DataSerializer; -import com.gemstone.gemfire.cache.Cache; -import com.gemstone.gemfire.cache.CacheFactory; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.execute.FunctionContext; -import com.gemstone.gemfire.internal.cache.PartitionedRegion; -import com.gemstone.gemfire.internal.tools.gfsh.aggregator.AggregateFunction; -import com.gemstone.gemfire.internal.tools.gfsh.aggregator.AggregateResults; -import com.gemstone.gemfire.internal.tools.gfsh.app.aggregator.AggregatorException; -import com.gemstone.gemfire.internal.tools.gfsh.app.aggregator.AggregatorPeer; -import com.gemstone.gemfire.internal.tools.gfsh.app.cache.index.Indexer; -import com.gemstone.gemfire.internal.tools.gfsh.app.cache.index.IndexerManager; -import com.gemstone.gemfire.internal.tools.gfsh.app.misc.util.DataSerializerEx; -import com.gemstone.gemfire.internal.tools.gfsh.command.CommandResults; -import com.gemstone.gemfire.internal.tools.gfsh.command.CommandTask; - -public class QuerySizeTask implements CommandTask, AggregateFunction -{ - private static final long serialVersionUID = 1L; - - private transient volatile boolean aggregationExecuted = false; - private final Object aggregationExecutedLock = new Object(); - - private String regionPath; - private Object queryKey; - - public QuerySizeTask() {} - - public QuerySizeTask(String regionPath, Object queryKey) - { - this.regionPath = regionPath; - this.queryKey = queryKey; - } - - public CommandResults runTask(Object userData) - { - Cache cache = CacheFactory.getAnyInstance(); - cache.getLogger().fine("QuerySizeTask.runTask(): regionPath = " + regionPath + ", queryKey = " + queryKey); - - CommandResults results = new CommandResults(); - - Region region = cache.getRegion(regionPath); - if (region == null) { - results.setCode(QueryTask.ERROR_REGION_UNDEFINED); - results.setCodeMessage("The specified region " + regionPath + " is undefined."); - return results; - } - - if (region instanceof PartitionedRegion) { - - // Partitioned Region - AggregatorPeer aggregator = new AggregatorPeer((PartitionedRegion)region); - try { - Object obj = aggregator.aggregate(this); - results.setCode(QueryTask.SUCCESS_PR); - results.setDataObject(obj); - } catch (AggregatorException ex) { - results.setCode(QueryTask.ERROR_AGGREGATOR); - results.setCodeMessage("Unabled to create aggregator: " + ex.getMessage()); - ex.printStackTrace(); - } - - } else { - - // Replicated Region - results.setCode(QueryTask.SUCCESS_RR); - results.setDataObject(size()); - } - - return results; - } - - public AggregateResults run(FunctionContext context) - { - AggregateResults results = null; - synchronized (aggregationExecutedLock) { - if (aggregationExecuted == false) { - results = new AggregateResults(); - results.setDataObject(size()); - aggregationExecuted = true; - } - } - return results; - } - - public Object aggregate(List list) - { - int totalSize = 0; - Iterator<AggregateResults> iterator = list.iterator(); - while (iterator.hasNext()) { - AggregateResults results = iterator.next(); - if (results != null) { - Integer size = (Integer)results.getDataObject(); - if (size != null) { - totalSize += size; - } - } - } - return totalSize; - } - - public Object aggregateDistributedSystems(Object[] results) - { - // Not supported - return null; - } - - private int size() - { - Indexer indexer = IndexerManager.getIndexerManager().getIndexer(regionPath); - return indexer.size(queryKey); - } - - public void fromData(DataInput in) throws IOException, - ClassNotFoundException - { - regionPath = DataSerializerEx.readUTF(in); - queryKey = DataSerializer.readObject(in); - } - - public void toData(DataOutput out) throws IOException - { - DataSerializerEx.writeUTF(regionPath, out); - DataSerializer.writeObject(queryKey, out); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/task/QueryTask.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/task/QueryTask.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/task/QueryTask.java deleted file mode 100644 index ccd75c6..0000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/cache/index/task/QueryTask.java +++ /dev/null @@ -1,323 +0,0 @@ -package com.gemstone.gemfire.internal.tools.gfsh.app.cache.index.task; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.CopyOnWriteArraySet; - -import com.gemstone.gemfire.DataSerializer; -import com.gemstone.gemfire.cache.Cache; -import com.gemstone.gemfire.cache.CacheFactory; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.execute.FunctionContext; -import com.gemstone.gemfire.internal.cache.PartitionedRegion; -import com.gemstone.gemfire.internal.util.BlobHelper; -import com.gemstone.gemfire.internal.tools.gfsh.aggregator.AggregateFunction; -import com.gemstone.gemfire.internal.tools.gfsh.aggregator.AggregateResults; -import com.gemstone.gemfire.internal.tools.gfsh.app.aggregator.AggregatorException; -import com.gemstone.gemfire.internal.tools.gfsh.app.aggregator.AggregatorPeer; -import com.gemstone.gemfire.internal.tools.gfsh.app.cache.index.Indexer; -import com.gemstone.gemfire.internal.tools.gfsh.app.cache.index.IndexerManager; -import com.gemstone.gemfire.internal.tools.gfsh.app.misc.util.DataSerializerEx; -import com.gemstone.gemfire.internal.tools.gfsh.command.CommandResults; -import com.gemstone.gemfire.internal.tools.gfsh.command.CommandTask; - -public class QueryTask implements CommandTask, AggregateFunction -{ - private static final long serialVersionUID = 1L; - - public final static byte TYPE_KEYS = 0; - public final static byte TYPE_VALUES = 1; - public final static byte TYPE_KEYS_VALUES = 2; - - public final static byte ERROR_NO_ERROR = CommandResults.CODE_NORMAL; - public final static byte ERROR_REGION_UNDEFINED = -2; - public final static byte ERROR_INDEX_UNDEFINED = -3; - public final static byte ERROR_AGGREGATOR = -3; - - public final static byte SUCCESS_RR = 1; //CommandResults.CODE_NORMAL + 1; - public final static byte SUCCESS_PR = 2; //CommandResults.CODE_NORMAL + 2; - - private transient volatile boolean aggregationExecuted = false; - private final Object aggregationExecutedLock = new Object(); - - private String regionPath; - private Object queryKey; - private byte queryType = TYPE_KEYS_VALUES; - -// private AggregatorPeer aggregator; - - private static Set<Integer> routingKeySet; - - static { - int numVMs = Integer.getInteger("indexer.aggregator.routingKeySize", 4); - routingKeySet = new CopyOnWriteArraySet<Integer>(); - for (int i = 0; i < numVMs; i++) { - routingKeySet.add(i); - } - } - - public QueryTask() {} - - public QueryTask(String regionPath, Object queryKey, byte queryType) - { - this.regionPath = regionPath; - this.queryKey = queryKey; - this.queryType = queryType; - } - - public CommandResults runTask(Object userData) - { - Cache cache = CacheFactory.getAnyInstance(); - cache.getLogger().fine("QueryTask.runTask(): regionPath = " + regionPath + ", type = " + queryType + ", queryKey = " + queryKey); - - CommandResults results = new CommandResults(); - - Region region = cache.getRegion(regionPath); - if (region == null) { - results.setCode(ERROR_REGION_UNDEFINED); - results.setCodeMessage("The specified region " + regionPath + " is undefined."); - return results; - } - - if (region instanceof PartitionedRegion) { - - // Partitioned Region - AggregatorPeer aggregator = new AggregatorPeer((PartitionedRegion)region); - try { - Object obj = aggregator.aggregate(this); - results.setCode(SUCCESS_PR); - results.setDataObject(obj); - } catch (AggregatorException ex) { - results.setCode(ERROR_AGGREGATOR); - results.setCodeMessage("Unabled to create aggregator: " + ex.getMessage()); - ex.printStackTrace(); - } - - } else { - - // Replicated Region - Indexer indexer = IndexerManager.getIndexerManager().getIndexer(regionPath); - if (indexer == null) { - results.setCode(ERROR_INDEX_UNDEFINED); - results.setCodeMessage("The indexer for the specified region " + regionPath + " is undefined."); - return results; - } - results.setCode(SUCCESS_RR); - results.setDataObject(run(indexer)); - - } - return results; - } - - public AggregateResults run(FunctionContext context) - { - AggregateResults results = null; - synchronized (aggregationExecutedLock) { - if (aggregationExecuted == false) { - results = new AggregateResults(); - Indexer indexer = IndexerManager.getIndexerManager().getIndexer(regionPath); - results.setDataObject(run(indexer)); - aggregationExecuted = true; - } - } - return results; - } - - public Object aggregate(List list) - { - Object aggregateResults = null; - - switch (queryType) { - - // Set - case TYPE_KEYS: - try { - Set aggregateSet = null; - Iterator iterator = list.iterator(); - while (iterator.hasNext()) { - AggregateResults results = (AggregateResults)iterator.next(); - byte[] blob = (byte[])results.getDataObject(); - if (blob != null) { - Set set = (Set)BlobHelper.deserializeBlob(blob); - if (aggregateSet == null) { - aggregateSet = set; - } else { - aggregateSet.addAll(set); - } - } - } - aggregateResults = aggregateSet; - } catch (Exception ex) { - CacheFactory.getAnyInstance().getLogger().warning("Error occurred while deserializing to blob: " + ex.getMessage(), ex); - } - break;//FindBugs - Usually you need to end this 'case' with a break or return. - - // Collection - case TYPE_VALUES: - try { - Collection aggregateCollection = null; - Iterator iterator = list.iterator(); - while (iterator.hasNext()) { - AggregateResults results = (AggregateResults)iterator.next(); - byte[] blob = (byte[])results.getDataObject(); - if (blob != null) { - Collection collection = (Collection)BlobHelper.deserializeBlob(blob); - if (aggregateCollection == null) { - aggregateCollection = collection; - } else { - aggregateCollection.addAll(collection); - } - } - } - aggregateResults = aggregateCollection; - } catch (Exception ex) { - CacheFactory.getAnyInstance().getLogger().warning("Error occurred while deserializing to blob: " + ex.getMessage(), ex); - } - break;//FindBugs - Usually you need to end this 'case' with a break or return. - - // Map - case TYPE_KEYS_VALUES: - default: - { - List aggregateList = new ArrayList(list.size()); - Iterator iterator = list.iterator(); - while (iterator.hasNext()) { - AggregateResults results = (AggregateResults)iterator.next(); - if (results != null) { - byte[] blob = (byte[])results.getDataObject(); - if (blob != null) { - aggregateList.add(blob); - } - } - } - aggregateResults = aggregateList; - break; - } - } - -// byte blob[] = null; -// if (aggregateResults != null) { -// try { -// blob = BlobHelper.serializeToBlob(aggregateResults); -// } catch (IOException ex) { -// CacheFactory.getAnyInstance().getLogger().warning("Error occurred while serializing to blob: " + ex.getMessage(), ex); -// } -// } -// -// return blob; - - return aggregateResults; - } - - public Object aggregateDistributedSystems(Object[] results) - { - // TODO Auto-generated method stub - return null; - } - - private Object run(Indexer indexer) - { - Object dataObject = null; - - switch (queryType) { - case TYPE_KEYS: - dataObject = queryKeys(indexer); - break; - case TYPE_VALUES: - dataObject = queryValues(indexer); - break; - case TYPE_KEYS_VALUES: - default: - dataObject = queryKeysValues(indexer); - break; - } - return dataObject; - } - - - private Object queryKeys(Indexer indexer) - { - byte[] blob = null; - - Map map = indexer.query(queryKey); - if (map != null) { - try { - // Need to serialize from here because "set" is - // synchronized in Indexer. - synchronized (map) { - blob = BlobHelper.serializeToBlob(new HashSet(map.keySet())); - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - map = null; // gc - - return blob; - } - - private Object queryValues(Indexer indexer) - { - byte[] blob = null; - - Map map = indexer.query(queryKey); - if (map != null) { - try { - // Need to serialize from here because "set" is - // synchronized in Indexer. - synchronized (map) { - blob = BlobHelper.serializeToBlob(new HashSet(map.values())); - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - map = null; // gc - return blob; - } - - private Object queryKeysValues(Indexer indexer) - { - byte[] blob = null; - - Map map = indexer.query(queryKey); - if (map != null) { - try { - // Need to serialize from here because "set" is - // synchronized in Indexer. - synchronized (map) { - blob = BlobHelper.serializeToBlob(map); - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - return blob; - } - - public void fromData(DataInput in) throws IOException, - ClassNotFoundException - { - regionPath = DataSerializerEx.readUTF(in); - queryKey = DataSerializer.readObject(in); - queryType = in.readByte(); - } - - public void toData(DataOutput out) throws IOException - { - DataSerializerEx.writeUTF(regionPath, out); - DataSerializer.writeObject(queryKey, out); - out.writeByte(queryType); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/command/CommandClient.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/command/CommandClient.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/command/CommandClient.java deleted file mode 100644 index 3b4914c..0000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/command/CommandClient.java +++ /dev/null @@ -1,417 +0,0 @@ -package com.gemstone.gemfire.internal.tools.gfsh.app.command; - -import java.util.ArrayList; -import java.util.UUID; - -import com.gemstone.gemfire.cache.CacheException; -import com.gemstone.gemfire.cache.DataPolicy; -import com.gemstone.gemfire.cache.EntryEvent; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.Scope; -import com.gemstone.gemfire.cache.client.Pool; -import com.gemstone.gemfire.cache.client.PoolManager; -import com.gemstone.gemfire.cache.query.SelectResults; -import com.gemstone.gemfire.cache.util.CacheListenerAdapter; -import com.gemstone.gemfire.internal.tools.gfsh.app.command.task.RegionCreateTask; -import com.gemstone.gemfire.internal.tools.gfsh.app.command.task.RegionDestroyTask; -import com.gemstone.gemfire.internal.tools.gfsh.app.command.task.data.RegionAttributeInfo; -import com.gemstone.gemfire.internal.tools.gfsh.command.AbstractCommandTask; -import com.gemstone.gemfire.internal.tools.gfsh.command.CommandResults; -import com.gemstone.gemfire.internal.tools.gfsh.command.CommandTask; -import com.gemstone.gemfire.internal.tools.gfsh.util.RegionUtil; - -/** - * CommandClient executes a CommandTask in the server. - * - * @author dpark - * - */ -public class CommandClient -{ - private static final String KEY_DEFAULT = "_command"; - private static final String KEY_BROADCAST = "_bcast"; - - private Region outboxRegion; - private String outboxRegionFullPath; - private String endpoints; - private Pool pool; - - private Region inboxRegion; - private boolean inboxEnabled = false; - - private ArrayList commandResultsListenerList = new ArrayList(5); - - private CommandResultsListener commandResultsListeners[] = new CommandResultsListener[0]; - - /** - * Constrcuts a new CommandClient object with the specified pool name or - * endpoints. If null, the default path "/__command" is assigned. - * - * @param outboxRegionFullPath - * The region full path. - * @param poolNameOrEndpoints - * The bridge client pool name or endpoints. The endpoints format - * is "e1=host:port,e2=host2:port". - * If the name is not in the endpoints format then it is treated - * as a pool name. If null, the region is created as - * a peer region if not already created. - * @throws CacheException - * Thrown if unable to create cache connection. - */ - public CommandClient(String outboxRegionFullPath, String poolNameOrEndpoints) throws CacheException - { - this(outboxRegionFullPath, poolNameOrEndpoints, isPoolName(poolNameOrEndpoints)); -// FindBugs - endpoints uninited & seems to be used by mistake, should have been poolNameOrEndpoints -// init(outboxRegionFullPath, endpoints, isPoolName(poolNameOrEndpoints)); - } - - /** - * Creates a CommandClient object with the specified pool or endpoints. - * @param outboxRegionFullPath The outbox region path. If null, the default path "/__command" is assigned. - * @param poolNameOrEndpoints Pool name or endpoints. - * @param isPool true if pool name, false if endpoints. - */ - public CommandClient(String outboxRegionFullPath, String poolNameOrEndpoints, boolean isPool) - { - init(outboxRegionFullPath, poolNameOrEndpoints, isPool); - } - - private static boolean isPoolName(String poolNameOrEndpoints) - { - return poolNameOrEndpoints.indexOf(":") != -1; - } - - private void init(String outboxRegionFullPath, String poolNameOrEndpoints, boolean isPool) - { - if (outboxRegionFullPath == null) - { - this.outboxRegionFullPath = "__command"; - } - else - { - this.outboxRegionFullPath = outboxRegionFullPath; - } - if (isPool) - { - pool = PoolManager.find(poolNameOrEndpoints); - outboxRegion = RegionUtil.getRegion(this.outboxRegionFullPath, Scope.LOCAL, DataPolicy.EMPTY, pool, false); - } - else - { - endpoints = poolNameOrEndpoints; - outboxRegion = RegionUtil.getRegion(this.outboxRegionFullPath, Scope.LOCAL, DataPolicy.EMPTY, endpoints, false); - } - } - - /** - * Constructs a new Command Client object with the specified pool. - * @param outboxRegionFullPath - * @param pool The pool. - * @throws CacheException Thrown if unable to create cache connection. - */ - public CommandClient(String outboxRegionFullPath, Pool pool) throws CacheException - { - if (outboxRegionFullPath == null) { - this.outboxRegionFullPath = "__command"; - } else { - this.outboxRegionFullPath = outboxRegionFullPath; - } - this.pool = pool; - outboxRegion = RegionUtil.getRegion(this.outboxRegionFullPath, Scope.LOCAL, DataPolicy.EMPTY, pool, false); - } - - /** - * Constructs a CommandClient object with the default region "__command". - * @param poolNameOrEndpoints - * The bridge client pool name or endpoints. The endpoints format - * is "e1=host:port,e2=host2:port". - * If the name is not in the endpoints format then it is treated - * as a pool name. If null, the region is created as - * a peer region if not already created. - * @throws CacheException Thrown if unable to create cache connection. - */ - public CommandClient(String poolNameOrEndpoints) throws CacheException - { - this(null, poolNameOrEndpoints); - } - - /** - * Creates a CommandClient object that uses the default command region name, - * "_command". - * - * @param pool - */ - public CommandClient(Pool pool) - { - this.pool = pool; - } - - /** - * Executes the specified command task. - * <p> - * The server must have CommandServerManager registered with writer disabled - * for this method to work. - * - * @param task - * The command task to execute in the server. - * @param isBroadcast - * true to broadcast the command execution to all peers. false to - * execute on one of the servers. - * @return Returns CommandResults returned by CommandTask.runTask(). - */ - private CommandResults execute(CommandTask task, boolean isBroadcast) - { - if (isClosed()) { - return null; - } - - CommandResults results; - if (isInboxEnabled()) { - if (task instanceof AbstractCommandTask) { - ((AbstractCommandTask) task).setResultSetRegionPath(inboxRegion.getFullPath()); - } - } - if (isBroadcast) { - return (CommandResults) outboxRegion.get(KEY_BROADCAST, task); - } else { - return (CommandResults) outboxRegion.get(KEY_DEFAULT, task); - } - } - - /** - * Executes the specified command task. - * <p> - * The server must have CommandServerManager registered with writer disabled - * for this method to work. - * - * @param task - * The command task to execute in the server. - * @return Returns CommandResults returned by CommandTask.runTask(). - */ - public CommandResults execute(CommandTask task) - { - return execute(task, false); - } - - /** - * Broadcasts the specified command task. - * <p> - * The server must have CommandServerManager registered with writer disabled - * for this method to work. - * - * @param task - * The command task to execute in the server. - * @return Returns CommandResults returned by CommandTask.runTask(). - */ - public CommandResults broadcast(CommandTask task) - { - return execute(task, true); - } - - /** - * Executes the task. The data object is passed to CommandTask.runTask() as - * user data, which has the type SerializedCacheValue. CommandTask.runTask() - * can inflate the serialized object to its actual type or send it to other - * GemFire members as a serialized object. - * <p> - * The server must have CommandServerManager registered with the writer - * enabled for this method to work. - * - * @param task - * @param dataObject - */ - public void execute(CommandTask task, Object dataObject) - { - if (isClosed()) { - return; - } - - outboxRegion.put(task, dataObject); - } - - public void setInboxEnabled(boolean inboxEnabled) throws CommandException - { - if (isClosed()) { - return; - } - this.inboxEnabled = inboxEnabled; - setUniqueInbox(outboxRegion.getFullPath()); - } - - public boolean isInboxEnabled() - { - return inboxEnabled; - } - - /** - * Closes CommandClient. This object is no longer usable after this method - * call. - */ - public void close() throws CommandException - { - CommandResults results = null; - if (inboxRegion != null) { - results = broadcast(new RegionDestroyTask(inboxRegion.getFullPath())); - inboxRegion = null; - inboxEnabled = false; - } - - // Destroying the outboxRegion also destroys its child region - // inboxRegion. - if (outboxRegion != null) { - outboxRegion.localDestroyRegion(); - outboxRegion = null; - } - - if (results != null && results.getCode() == RegionDestroyTask.ERROR_REGION_DESTROY) { - throw new CommandException("Server may have not destroyed the client command region(s)", results - .getException()); - } - } - - public boolean isClosed() - { - return outboxRegion == null; - } - - public String getInboxRegionFullPath() - { - if (inboxRegion == null) { - return null; - } - return inboxRegion.getFullPath(); - } - - private String createUniqueRegionName() throws Exception - { - UUID uuid = UUID.randomUUID(); - return uuid.toString(); - } - - /** - * Creates a unique inbox region under the specified regionFullPath. - * - * @param regionFullPath - * The full path of the region in which a unique (and therefore - * private) inbox region is created. - */ - private void setUniqueInbox(String regionFullPath) throws CommandException - { - if (regionFullPath == null) { - inboxRegion = null; - return; - } - - try { - String inboxPath = regionFullPath + "/" + createUniqueRegionName(); - RegionAttributeInfo attrInfo = new RegionAttributeInfo(); - attrInfo.setAttribute(RegionAttributeInfo.SCOPE, "local"); - attrInfo.setAttribute(RegionAttributeInfo.DATA_POLICY, "empty"); - CommandResults results = broadcast(new RegionCreateTask(inboxPath, attrInfo)); - - if (results.getCode() == RegionCreateTask.ERROR_REGION_NOT_CREATED) { - throw new CommandException("Unable to create a CommandResults reply region in the server.", results - .getException()); //FindBugs - forgets to throw new CommandException(String, Throwable) - } - - if (endpoints != null) { - inboxRegion = RegionUtil.getRegion(inboxPath, Scope.LOCAL, DataPolicy.DEFAULT, endpoints, false); - } else { - inboxRegion = RegionUtil.getRegion(inboxPath, Scope.LOCAL, DataPolicy.DEFAULT, pool, false); - } - inboxRegion.getAttributesMutator().addCacheListener(new ReplyListener()); - inboxRegion.registerInterestRegex(".*"); - } catch (Exception ex) { - throw new CommandException(ex); - } - } - - public SelectResults query(String queryString) throws CommandException - { - if (isClosed()) { - return null; - } - - try { - return outboxRegion.query(queryString); - } catch (Exception ex) { - throw new CommandException(ex); - } - } - - public String getOutboxRegionFullPath() - { - return outboxRegionFullPath; - } - - /** - * Returns the endpoints. If pool is used then it returns null. - */ - public String getEndpoints() - { - return endpoints; - } - - /** - * Returns the pool. If endpoints is used then it returns null. - */ - public Pool getPool() - { - return pool; - } - - /** - * Returns the pool name. If endpoints is used then it returns null. - */ - public String getPoolName() - { - if (pool == null) { - return null; - } else { - return pool.getName(); - } - } - - - public void addCommandResultsListener(CommandResultsListener commandResultsListener) - { - commandResultsListenerList.add(commandResultsListener); - commandResultsListeners = (CommandResultsListener[]) commandResultsListenerList - .toArray(new CommandResultsListener[0]); - } - - public void removeCommandResultsListener(CommandResultsListener commandResultsListener) - { - commandResultsListenerList.remove(commandResultsListener); - commandResultsListeners = (CommandResultsListener[]) commandResultsListenerList - .toArray(new CommandResultsListener[0]); - } - - protected void fireCommandResults(CommandResults results) - { - CommandResultsListener listeners[] = commandResultsListeners; - for (int i = 0; i < listeners.length; i++) { - listeners[i].commandResultsReceived(results); - } - } - - class ReplyListener extends CacheListenerAdapter - { - private void handleReplyReceived(EntryEvent entryEvent) - { - CommandResults results = (CommandResults) entryEvent.getNewValue(); - fireCommandResults(results); - } - - public void afterCreate(EntryEvent entryEvent) - { - handleReplyReceived(entryEvent); - } - - public void afterUpdate(EntryEvent entryEvent) - { - handleReplyReceived(entryEvent); - } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/command/CommandException.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/command/CommandException.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/command/CommandException.java deleted file mode 100644 index ebbeb4f..0000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/command/CommandException.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.gemstone.gemfire.internal.tools.gfsh.app.command; - -/** - * - * @author dpark - * - */ - - -public class CommandException extends Exception -{ - public CommandException() - { - super(); - } - public CommandException(String message) - { - super(message); - } - - public CommandException(String message, Throwable cause) - { - super(message, cause); - } - - public CommandException(Throwable cause) - { - super(cause); - } -} - http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/command/CommandResultsListener.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/command/CommandResultsListener.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/command/CommandResultsListener.java deleted file mode 100644 index 4712603..0000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/command/CommandResultsListener.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.gemstone.gemfire.internal.tools.gfsh.app.command; - -import com.gemstone.gemfire.internal.tools.gfsh.command.CommandResults; - - -/** - * CommandResultsListener asynchronously receives CommandResults sent by - * AbstractCommandTask.sendResults(). - * @author dpark - * - */ -public interface CommandResultsListener -{ - void commandResultsReceived(CommandResults commandResults); -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/command/task/EchoTask.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/command/task/EchoTask.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/command/task/EchoTask.java deleted file mode 100644 index cf29a12..0000000 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/command/task/EchoTask.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.gemstone.gemfire.internal.tools.gfsh.app.command.task; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - -import com.gemstone.gemfire.internal.tools.gfsh.command.CommandResults; -import com.gemstone.gemfire.internal.tools.gfsh.command.CommandTask; - -/** - * EchoTask returns itself back to the caller. CommandResults.getDataObject() - * returns EchoTask. - * @author dpark - * - */ -public class EchoTask implements CommandTask { - private static final long serialVersionUID = 1L; - - public static final byte ERROR_REGION_DESTROY = 1; - - private String message; - - public EchoTask() { - } - - public EchoTask(String message) { - this.message = message; - } - - public CommandResults runTask(Object userData) { - CommandResults results = new CommandResults(); - results.setDataObject(this); - return results; - } - - private void writeUTF(String value, DataOutput output) throws IOException - { - if (value == null) { - output.writeUTF("\0"); - } else { - output.writeUTF(value); - } - } - - private String readUTF(DataInput in) throws IOException - { - String value = in.readUTF(); - if (value.equals("\0")) { - value = null; - } - return value; - } - - public void fromData(DataInput input) throws IOException, - ClassNotFoundException { - message = readUTF(input); - } - - public void toData(DataOutput output) throws IOException { - writeUTF(message, output); - } - -}
