You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geode.apache.org by "Swapnil Bawaskar (JIRA)" <ji...@apache.org> on 2017/05/26 19:31:04 UTC

[jira] [Created] (GEODE-3001) Need to document how to insert/remove objects from gfsh

Swapnil Bawaskar created GEODE-3001:
---------------------------------------

             Summary: Need to document how to insert/remove objects from gfsh
                 Key: GEODE-3001
                 URL: https://issues.apache.org/jira/browse/GEODE-3001
             Project: Geode
          Issue Type: Task
          Components: docs
            Reporter: Swapnil Bawaskar


In addition to simple primitives, gfsh put/remove commands can specify domain object keys and values expressed as json.

Say you have the following domain object that you would like to use as key:
{noformat}
package io.pivotal.gemfire.testing;

import java.io.Serializable;
public class MyKey implements Serializable {
 private static final long serialVersionUID = 2552455191256578368L;
  private String identifier;
  private String name;
  public MyKey(){
  }

  public MyKey(String identifier, String name){
    this.identifier=identifier;
    this.name=name;
  }

  public String getIdentifier() {
    return identifier;
  }

  public void setIdentifier(String identifier) {
    this.identifier = identifier;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  @Override public boolean equals(Object obj) {
    if (obj instanceof MyKey) {
      MyKey other = (MyKey) obj;
      if (this.identifier.equals(other.getIdentifier())
          && this.name.equals(other.getName())) {
        return true;
      }
    }
    return false;
  }

  @Override public int hashCode() {
    return this.identifier.hashCode()/31 + this.name.hashCode()/31;
  }
}
{noformat}

You can use the object as json like so:
{noformat}
gfsh>put --key-class=io.pivotal.gemfire.testing.MyKey --key="{'identifier': 'KIWI131117+65', 'name':'name'}" --value=foo2 --region=/foo
{noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)