Package com.taobao.tdhs.client.response

Examples of com.taobao.tdhs.client.response.TDHSResponse


            }
            if (!TDHSResponseEnum.ClientStatus.MULTI_STATUS.equals(ret.getClientStatus())) {
                if (ret.getClientStatus() != null && ret.getClientStatus().getStatus() >= 400 &&
                        ret.getClientStatus().getStatus() < 600) {
                    throw new TDHSBatchException(
                            new TDHSResponse(ret.getClientStatus(), null, ret.getData(), charsetName));
                } else {
                    throw new TDHSException("unknown response code! [" + (ret.getClientStatus() != null ?
                            String.valueOf(ret.getClientStatus().getStatus()) : "") + "]");
                }
            }
            if (ret.getBatchNumber() != batchRequest.size()) {
                throw new TDHSException(
                        "unmatch batch size! request is[" + String.valueOf(batchRequest.size()) + "], response is [" +
                                String.valueOf(ret.getBatchNumber()) + "]");
            }

            TDHSResponse result[] = new TDHSResponse[batchRequest.size()];
            int i = 0;
            for (internal_struct is : batchRequest) {
                result[i++] =
                        do_response(responses.get(is.getPacket().getSeqId()), is.getMetaData(), is.getCharsetName());
            }
View Full Code Here


    TableInfo tableInfo = new TableInfo(db, table, index, fields);
    Insert insert = new Insert(tableInfo);
    insert.addValue(id);
    insert.addValue(name);
    insert.addValue(level);
    TDHSResponse r = client.insert(insert);

    Assert.assertEquals(ClientStatus.OK, r.getStatus());
  }
View Full Code Here

  @After
  public void clean() throws TDHSException {
    TableInfo tableInfo = new TableInfo(db, table, index, fields);
    Get get = new Get(tableInfo, new String[][] { { name } },
        FindFlag.TDHS_EQ, 0, 20);
    TDHSResponse r = client.delete(get);

    Assert.assertEquals("1", r.getFieldData().get(0).get(0));
    Assert.assertEquals(ClientStatus.OK, r.getStatus());
  }
View Full Code Here

  @Test
  public void testUpdate1() throws TDHSException {
    try {
      ValueEntry entry = new ValueEntry(UpdateFlag.TDHS_UPDATE_SET, "5");
      TDHSResponse r = client.update(db, table, null,
          new String[] { fields[0] }, new ValueEntry[] { entry },
          new String[][] { { id } }, FindFlag.TDHS_EQ, 0, 100, null);

      Assert.assertEquals("1", r.getFieldData().get(0).get(0));
      Assert.assertEquals(ClientStatus.OK, r.getStatus());
      id = "5";
    } catch (TDHSException e) {
      throw new TDHSException("Update exception:" + e.getMessage());
    }
  }
View Full Code Here

  @Test
  public void testUpdate2() throws TDHSException {
    try {
      ValueEntry entry = new ValueEntry(UpdateFlag.TDHS_UPDATE_ADD, "5");
      TDHSResponse r = client.update(db, table, null,
          new String[] { fields[0] }, new ValueEntry[] { entry },
          new String[][] { { id } }, FindFlag.TDHS_EQ, 0, 100, null);

      Assert.assertEquals("1", r.getFieldData().get(0).get(0));
      Assert.assertEquals(ClientStatus.OK, r.getStatus());
      id = Integer.parseInt(id) + 5 + "";
    } catch (Exception e) {
      throw new TDHSException("Update exception:" + e.getMessage());
    }
  }
View Full Code Here

  @Test
  public void testUpdate3() throws TDHSException {
    try {
      ValueEntry entry = new ValueEntry(UpdateFlag.TDHS_UPDATE_SUB, "5");
      TDHSResponse r = client.update(db, table, null,
          new String[] { fields[0] }, new ValueEntry[] { entry },
          new String[][] { { id } }, FindFlag.TDHS_EQ, 0, 100, null);

      Assert.assertEquals("1", r.getFieldData().get(0).get(0));
      Assert.assertEquals(ClientStatus.OK, r.getStatus());
      id = Integer.parseInt(id) - 5 + "";
    } catch (Exception e) {
      throw new TDHSException("Update exception:" + e.getMessage());
    }
  }
View Full Code Here

          new String[] { fields[0] });
      // keys与上面index对应
      Get get = new Get(tableInfo, new String[][] { { name } },
          FindFlag.TDHS_EQ, 0, 20);

      TDHSResponse r = client.get(get);
      ResultSet rs = r.getResultSet();
      int c = 0;
      while (rs.next()) {
        c++;
      }
      Assert.assertEquals(ClientStatus.OK, r.getStatus());
      Assert.assertEquals(c, r.getFieldData().size());
    } catch (TDHSException e) {
      throw new TDHSException("Get exception:" + e.getMessage());
    }
  }
View Full Code Here

  @Test
  public void testGet02() throws TDHSException {
    try {
      Filter f = new Filter(fields[2], FilterFlag.TDHS_EQ, level);
      TDHSResponse r = client.get(db, table, index, new String[] {
          fields[0], fields[2] }, new String[][] { { name } },
          FindFlag.TDHS_EQ, 0, 100, new Filter[] { f });

      Assert.assertEquals(ClientStatus.OK, r.getStatus());
      Assert.assertEquals(1, r.getFieldData().size());
    } catch (TDHSException e) {
      throw new TDHSException("Get1 exception", e);
    }

    try {
      Filter f = new Filter(fields[2], FilterFlag.TDHS_GE, level);
      TDHSResponse r = client.get(db, table, index, new String[] {
          fields[0], fields[2] }, new String[][] { { name } },
          FindFlag.TDHS_EQ, 0, 100, new Filter[] { f });
      Assert.assertEquals(ClientStatus.OK, r.getStatus());
      Assert.assertEquals(1, r.getFieldData().size());
    } catch (TDHSException e) {
      throw new TDHSException("Get1 exception", e);
    }
  }
View Full Code Here

  @Test
  public void testGet03() throws TDHSException {
    try {
      Filter f = new Filter(fields[2], FilterFlag.TDHS_LE, level);
      TDHSResponse r = client.get(db, table, index, new String[] {
          fields[0], fields[2] }, new String[][] { { name } },
          FindFlag.TDHS_EQ, 0, 100, new Filter[] { f });
      Assert.assertEquals(ClientStatus.OK, r.getStatus());
      Assert.assertEquals(1, r.getFieldData().size());
    } catch (TDHSException e) {
      throw new TDHSException("Get1 exception", e);
    }
  }
View Full Code Here

  @Test
  public void testGet04() throws TDHSException {
    try {
      Filter f = new Filter(fields[2], FilterFlag.TDHS_GT, level);
      TDHSResponse r = client.get(db, table, index, new String[] {
          fields[0], fields[2] }, new String[][] { { name } },
          FindFlag.TDHS_EQ, 0, 100, new Filter[] { f });
      Assert.assertEquals(ClientStatus.OK, r.getStatus());
      Assert.assertEquals(0, r.getFieldData().size());
    } catch (TDHSException e) {
      throw new TDHSException("Get1 exception", e);
    }
  }
View Full Code Here

TOP

Related Classes of com.taobao.tdhs.client.response.TDHSResponse

Copyright © 2018 www.massapicom. 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.