Package org.apache.accumulo.core.client.ConditionalWriter

Examples of org.apache.accumulo.core.client.ConditionalWriter.Result


    ConditionalWriter cw = conn.createConditionalWriter(tableName, new ConditionalWriterConfig().setAuthorizations(new Authorizations("A")));
    Iterator<Result> results = cw.write(mutations.iterator());
    int count = 0;
    while (results.hasNext()) {
      Result result = results.next();
      Assert.assertEquals(Status.ACCEPTED, result.getStatus());
      count++;
    }

    Assert.assertEquals(3, count);

    Scanner scanner = conn.createScanner(tableName, new Authorizations("A"));
    scanner.fetchColumn(new Text("tx"), new Text("seq"));

    for (String row : new String[] {"99006", "59056", "19059"}) {
      scanner.setRange(new Range(row));
      Assert.assertEquals("1", scanner.iterator().next().getValue().toString());
    }

    TreeSet<Text> splits = new TreeSet<Text>();
    splits.add(new Text("7"));
    splits.add(new Text("3"));
    conn.tableOperations().addSplits(tableName, splits);

    mutations.clear();

    ConditionalMutation cm3 = new ConditionalMutation("99006", new Condition("tx", "seq").setVisibility(cvab).setValue("1"));
    cm3.put("name", "last", cvab, "Doe");
    cm3.put("tx", "seq", cvab, "2");
    mutations.add(cm3);

    ConditionalMutation cm4 = new ConditionalMutation("59056", new Condition("tx", "seq").setVisibility(cvab));
    cm4.put("name", "last", cvab, "Doe");
    cm4.put("tx", "seq", cvab, "1");
    mutations.add(cm4);

    ConditionalMutation cm5 = new ConditionalMutation("19059", new Condition("tx", "seq").setVisibility(cvab).setValue("2"));
    cm5.put("name", "last", cvab, "Doe");
    cm5.put("tx", "seq", cvab, "3");
    mutations.add(cm5);

    results = cw.write(mutations.iterator());
    int accepted = 0;
    int rejected = 0;
    while (results.hasNext()) {
      Result result = results.next();
      if (new String(result.getMutation().getRow()).equals("99006")) {
        Assert.assertEquals(Status.ACCEPTED, result.getStatus());
        accepted++;
      } else {
        Assert.assertEquals(Status.REJECTED, result.getStatus());
        rejected++;
      }
    }

    Assert.assertEquals(1, accepted);
View Full Code Here


    int count = 0;

    // TODO check got each row back
    while (results.hasNext()) {
      Result result = results.next();
      Assert.assertEquals(Status.ACCEPTED, result.getStatus());
      count++;
    }

    Assert.assertEquals(num, count);

    ArrayList<ConditionalMutation> cml2 = new ArrayList<ConditionalMutation>(num);

    for (int i = 0; i < num; i++) {
      ConditionalMutation cm = new ConditionalMutation(rows.get(i), new Condition("meta", "seq").setValue("1"));

      cm.put("meta", "seq", "2");
      cm.put("meta", "tx", UUID.randomUUID().toString());

      cml2.add(cm);
    }

    count = 0;

    results = cw.write(cml2.iterator());

    while (results.hasNext()) {
      Result result = results.next();
      Assert.assertEquals(Status.ACCEPTED, result.getStatus());
      count++;
    }

    Assert.assertEquals(num, count);
View Full Code Here

    ConditionalWriter cw = conn.createConditionalWriter(tableName, new ConditionalWriterConfig().setAuthorizations(new Authorizations("A")));
    Iterator<Result> results = cw.write(mutations.iterator());
    HashSet<String> rows = new HashSet<String>();
    while (results.hasNext()) {
      Result result = results.next();
      String row = new String(result.getMutation().getRow());
      if (row.equals("19059")) {
        Assert.assertEquals(Status.ACCEPTED, result.getStatus());
      } else if (row.equals("59056")) {
        Assert.assertEquals(Status.INVISIBLE_VISIBILITY, result.getStatus());
      } else if (row.equals("99006")) {
        Assert.assertEquals(Status.VIOLATED, result.getStatus());
      } else if (row.equals("90909")) {
        Assert.assertEquals(Status.REJECTED, result.getStatus());
      }
      rows.add(row);
    }

    Assert.assertEquals(4, rows.size());
View Full Code Here

      mutations.add(new Stats(row).toMutation());

    ArrayList<ByteSequence> rows2 = new ArrayList<ByteSequence>();
    Iterator<Result> results = cw.write(mutations.iterator());
    while (results.hasNext()) {
      Result result = results.next();
      Assert.assertEquals(Status.ACCEPTED, result.getStatus());
      rows2.add(new ArrayByteSequence(result.getMutation().getRow()));
    }

    Collections.sort(rows);
    Collections.sort(rows2);
View Full Code Here

    ConditionalMutation cm1 = new ConditionalMutation("r1", new Condition("tx", "seq"));
    cm1.put("tx", "seq", "1");
    cm1.put("data", "x", "a");

    Result result = cw.write(cm1);

    try {
      result.getStatus();
      Assert.assertFalse(true);
    } catch (AccumuloException ae) {
      Assert.assertEquals(TableDeletedException.class, ae.getCause().getClass());
    }
  }
View Full Code Here

    ConditionalMutation cm1 = new ConditionalMutation("r1", new Condition("tx", "seq"));
    cm1.put("tx", "seq", "1");
    cm1.put("data", "x", "a");

    Result result = cw.write(cm1);

    try {
      result.getStatus();
      Assert.assertFalse(true);
    } catch (AccumuloException ae) {
      Assert.assertEquals(TableOfflineException.class, ae.getCause().getClass());
    }
View Full Code Here

    ConditionalMutation cm1 = new ConditionalMutation("r1", new Condition("tx", "seq").setIterators(iterSetting));
    cm1.put("tx", "seq", "1");
    cm1.put("data", "x", "a");

    Result result = cw.write(cm1);

    try {
      result.getStatus();
      Assert.assertFalse(true);
    } catch (AccumuloException ae) {

    }
View Full Code Here

      Iterator<Result> results = cw.write(cmuts.iterator());
     
      HashMap<ByteBuffer,ConditionalStatus> resultMap = new HashMap<ByteBuffer,ConditionalStatus>();
     
      while (results.hasNext()) {
        Result result = results.next();
        ByteBuffer row = ByteBuffer.wrap(result.getMutation().getRow());
        ConditionalStatus status = ConditionalStatus.valueOf(result.getStatus().name());
        resultMap.put(row, status);
      }
     
      return resultMap;
    } catch (Exception e) {
View Full Code Here

          }

          ArrayList<ByteSequence> changed = new ArrayList<ByteSequence>(numRows);
          Iterator<Result> results = cw.write(mutations.iterator());
          while (results.hasNext()) {
            Result result = results.next();
            changed.add(new ArrayByteSequence(result.getMutation().getRow()));
          }

          Collections.sort(changes);
          Collections.sort(changed);
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.client.ConditionalWriter.Result

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.