Examples of BSONObject


Examples of org.bson.BSONObject

  @Test
  public void testValidMultipleCalls() throws IOException, GoRpcException, ApplicationException {
    Client client = Client.dialHttp(Util.HOST, Util.PORT, Util.PATH, new BsonClientCodecFactory());

    BSONObject mArgs = new BasicBSONObject();
    mArgs.put("A", 5L);
    mArgs.put("B", 7L);
    Response response = client.call("Arith.Multiply", mArgs);
    Assert.assertEquals(35L, response.getReply());

    mArgs = new BasicBSONObject();
    mArgs.put("A", 2L);
    mArgs.put("B", 3L);
    response = client.call("Arith.Multiply", mArgs);
    Assert.assertEquals(6L, response.getReply());

    client.close();
  }
View Full Code Here

Examples of org.bson.BSONObject

  @Test
  public void testCallOnClosedClient() throws IOException, GoRpcException, ApplicationException {
    Client client = Client.dialHttp(Util.HOST, Util.PORT, Util.PATH, new BsonClientCodecFactory());

    BSONObject mArgs = new BasicBSONObject();
    mArgs.put("A", 5L);
    mArgs.put("B", 7L);
    Response response = client.call("Arith.Multiply", mArgs);
    Assert.assertEquals(35L, response.getReply());
    client.close();

    try {
View Full Code Here

Examples of org.bson.BSONObject

    }

    if (response == null) {
      return null;
    }
    BSONObject reply = (BSONObject) response.getReply();
    if (reply.containsField("Result")) {
      BSONObject result = (BSONObject) reply.get("Result");
      return Bsonify.bsonToQueryResult(result, fields);
    }
    return null;
  }
View Full Code Here

Examples of org.bson.BSONObject

      throw new IllegalArgumentException("Can not parse message " + message.getClass());
    }
  }

  protected BSONObject create(Query query) {
    BSONObject bsonMessage = new BasicBSONObject();
    bsonMessage.put("TransactionId", query.getSession().getTransactionId());
    bsonMessage.put("SessionId", query.getSession().getSessionId());
    bsonMessage.put("BindVariables", bindVariablesToMap(query.getBindVariablesList()));
    bsonMessage.put("Sql", query.getSql().toByteArray());
    return bsonMessage;
  }
View Full Code Here

Examples of org.bson.BSONObject

    bsonMessage.put("Sql", query.getSql().toByteArray());
    return bsonMessage;
  }

  protected BSONObject bindVariablesToMap(List<BindVariable> bindVariableList) {
    BSONObject bsonBindVariables = new BasicBSONObject();
    for (BindVariable bindVariable : bindVariableList) {
      addTypeField(bsonBindVariables, bindVariable);
    }
    return bsonBindVariables;
  }
View Full Code Here

Examples of org.bson.BSONObject

        break;
    }
  }

  protected BSONObject create(SessionParams sessionParams) {
    BSONObject bsonMessage = new BasicBSONObject();
    bsonMessage.put("Keyspace", sessionParams.getKeyspace());
    bsonMessage.put("Shard", sessionParams.getShard());
    return bsonMessage;
  }
View Full Code Here

Examples of org.bson.BSONObject

    bsonMessage.put("Shard", sessionParams.getShard());
    return bsonMessage;
  }

  protected BSONObject create(QueryList queryList) {
    BSONObject bsonQueryList = new BasicBSONObject();
    bsonQueryList.put("TransactionId", queryList.getSession().getTransactionId());
    bsonQueryList.put("SessionId", queryList.getSession().getSessionId());

    BasicBSONList bsonQueries = new BasicBSONList();
    for (int i = 0; i < queryList.getQueriesCount(); i++) {
      BoundQuery boundQuery = queryList.getQueries(i);
      BSONObject bsonQuery = new BasicBSONObject();
      bsonQuery.put("BindVariables", bindVariablesToMap(boundQuery.getBindVariablesList()));
      bsonQuery.put("Sql", boundQuery.getSql().toStringUtf8());
      bsonQueries.put(i, bsonQuery);
    }

    bsonQueryList.put("Queries", bsonQueries);
    return bsonQueryList;
View Full Code Here

Examples of org.bson.BSONObject

    return bsonQueryList;

  }

  protected BSONObject create(Session session) {
    BSONObject bsonMessage = new BasicBSONObject();
    bsonMessage.put("TransactionId", session.getTransactionId());
    bsonMessage.put("SessionId", session.getSessionId());
    return bsonMessage;
  }
View Full Code Here

Examples of org.bson.BSONObject

import java.util.List;
import java.util.Map;

public class Bsonify {
  public static BSONObject queryToBson(Query query) {
    BSONObject b = new BasicBSONObject();
    b.put("Sql", query.getSql());
    b.put("Keyspace", query.getKeyspace());
    b.put("TabletType", query.getTabletType());
    if (query.getBindVars() != null) {
      b.put("BindVariables", bindVarsToBSON(query.getBindVars()));
    }
    if (query.getKeyspaceIds() != null) {
      b.put("KeyspaceIds", query.getKeyspaceIds());
    } else {
      b.put("KeyRanges", query.getKeyRanges());
    }
    if (query.getSession() != null) {
      b.put("Session", query.getSession());
    }
    return b;
  }
View Full Code Here

Examples of org.bson.BSONObject

    }
    return b;
  }

  public static BSONObject bindVarsToBSON(List<BindVariable> bindVars) {
    BSONObject bindVariables = new BasicBSONObject();
    for (BindVariable b : bindVars) {
      if (b.getType().equals(BindVariable.Type.NULL)) {
        bindVariables.put(b.getName(), null);
      }
      if (b.getType().equals(BindVariable.Type.LONG)) {
        bindVariables.put(b.getName(), b.getLongVal());
      }
      if (b.getType().equals(BindVariable.Type.UNSIGNED_LONG)) {
        bindVariables.put(b.getName(), b.getULongVal());
      }
      if (b.getType().equals(BindVariable.Type.DOUBLE)) {
        bindVariables.put(b.getName(), b.getDoubleVal());
      }
      if (b.getType().equals(BindVariable.Type.BYTE_ARRAY)) {
        bindVariables.put(b.getName(), b.getByteArrayVal());
      }
    }
    return bindVariables;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.