Package org.apache.accumulo.server.constraints

Examples of org.apache.accumulo.server.constraints.MetadataConstraints


  public void testCheck() {
    Logger.getLogger(AccumuloConfiguration.class).setLevel(Level.ERROR);
    Mutation m = new Mutation(new Text("0;foo"));
    ColumnFQ.put(m, Constants.METADATA_PREV_ROW_COLUMN, new Value("1foo".getBytes()));
   
    MetadataConstraints mc = new MetadataConstraints();
   
    List<Short> violations = mc.check(null, m);
   
    assertNotNull(violations);
    assertEquals(1, violations.size());
    assertEquals(Short.valueOf((short) 3), violations.get(0));
   
    m = new Mutation(new Text("0:foo"));
    ColumnFQ.put(m, Constants.METADATA_PREV_ROW_COLUMN, new Value("1poo".getBytes()));
   
    violations = mc.check(null, m);
   
    assertNotNull(violations);
    assertEquals(1, violations.size());
    assertEquals(Short.valueOf((short) 4), violations.get(0));
   
    m = new Mutation(new Text("0;foo"));
    m.put(new Text("bad_column_name"), new Text(""), new Value("e".getBytes()));
   
    violations = mc.check(null, m);
   
    assertNotNull(violations);
    assertEquals(1, violations.size());
    assertEquals(Short.valueOf((short) 2), violations.get(0));
   
    m = new Mutation(new Text("!!<"));
    ColumnFQ.put(m, Constants.METADATA_PREV_ROW_COLUMN, new Value("1poo".getBytes()));
   
    violations = mc.check(null, m);
   
    assertNotNull(violations);
    assertEquals(2, violations.size());
    assertEquals(Short.valueOf((short) 4), violations.get(0));
    assertEquals(Short.valueOf((short) 5), violations.get(1));
   
    m = new Mutation(new Text("0;foo"));
    ColumnFQ.put(m, Constants.METADATA_PREV_ROW_COLUMN, new Value("".getBytes()));
   
    violations = mc.check(null, m);
   
    assertNotNull(violations);
    assertEquals(1, violations.size());
    assertEquals(Short.valueOf((short) 6), violations.get(0));
   
    m = new Mutation(new Text("0;foo"));
    ColumnFQ.put(m, Constants.METADATA_PREV_ROW_COLUMN, new Value("bar".getBytes()));
   
    violations = mc.check(null, m);
   
    assertEquals(null, violations);
   
    m = new Mutation(new Text("!0<"));
    ColumnFQ.put(m, Constants.METADATA_PREV_ROW_COLUMN, new Value("bar".getBytes()));
   
    violations = mc.check(null, m);
   
    assertEquals(null, violations);
   
    m = new Mutation(new Text("!1<"));
    ColumnFQ.put(m, Constants.METADATA_PREV_ROW_COLUMN, new Value("bar".getBytes()));
   
    violations = mc.check(null, m);
   
    assertNotNull(violations);
    assertEquals(1, violations.size());
    assertEquals(Short.valueOf((short) 4), violations.get(0));
   
View Full Code Here


  public void testCheck() {
    Logger.getLogger(AccumuloConfiguration.class).setLevel(Level.ERROR);
    Mutation m = new Mutation(new Text("0;foo"));
    TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.put(m, new Value("1foo".getBytes()));
   
    MetadataConstraints mc = new MetadataConstraints();
   
    List<Short> violations = mc.check(null, m);
   
    assertNotNull(violations);
    assertEquals(1, violations.size());
    assertEquals(Short.valueOf((short) 3), violations.get(0));
   
    m = new Mutation(new Text("0:foo"));
    TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.put(m, new Value("1poo".getBytes()));
   
    violations = mc.check(null, m);
   
    assertNotNull(violations);
    assertEquals(1, violations.size());
    assertEquals(Short.valueOf((short) 4), violations.get(0));
   
    m = new Mutation(new Text("0;foo"));
    m.put(new Text("bad_column_name"), new Text(""), new Value("e".getBytes()));
   
    violations = mc.check(null, m);
   
    assertNotNull(violations);
    assertEquals(1, violations.size());
    assertEquals(Short.valueOf((short) 2), violations.get(0));
   
    m = new Mutation(new Text("!!<"));
    TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.put(m, new Value("1poo".getBytes()));
   
    violations = mc.check(null, m);
   
    assertNotNull(violations);
    assertEquals(2, violations.size());
    assertEquals(Short.valueOf((short) 4), violations.get(0));
    assertEquals(Short.valueOf((short) 5), violations.get(1));
   
    m = new Mutation(new Text("0;foo"));
    TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.put(m, new Value("".getBytes()));
   
    violations = mc.check(null, m);
   
    assertNotNull(violations);
    assertEquals(1, violations.size());
    assertEquals(Short.valueOf((short) 6), violations.get(0));
   
    m = new Mutation(new Text("0;foo"));
    TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.put(m, new Value("bar".getBytes()));
   
    violations = mc.check(null, m);
   
    assertEquals(null, violations);
   
    m = new Mutation(new Text("!0<"));
    TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.put(m, new Value("bar".getBytes()));
   
    violations = mc.check(null, m);
   
    assertEquals(null, violations);
   
    m = new Mutation(new Text("!1<"));
    TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.put(m, new Value("bar".getBytes()));
   
    violations = mc.check(null, m);
   
    assertNotNull(violations);
    assertEquals(1, violations.size());
    assertEquals(Short.valueOf((short) 4), violations.get(0));
   
View Full Code Here

   
  }
 
  @Test
  public void testBulkFileCheck() {
    MetadataConstraints mc = new TestMetadataConstraints();
    Mutation m;
    List<Short> violations;
   
    // inactive txid
    m = new Mutation(new Text("0;foo"));
    m.put(TabletsSection.BulkFileColumnFamily.NAME, new Text("/someFile"), new Value("12345".getBytes()));
    m.put(DataFileColumnFamily.NAME, new Text("/someFile"), new Value("1,1".getBytes()));
    violations = mc.check(null, m);
    assertNotNull(violations);
    assertEquals(1, violations.size());
    assertEquals(Short.valueOf((short) 8), violations.get(0));
   
    // txid that throws exception
    m = new Mutation(new Text("0;foo"));
    m.put(TabletsSection.BulkFileColumnFamily.NAME, new Text("/someFile"), new Value("9".getBytes()));
    m.put(DataFileColumnFamily.NAME, new Text("/someFile"), new Value("1,1".getBytes()));
    violations = mc.check(null, m);
    assertNotNull(violations);
    assertEquals(1, violations.size());
    assertEquals(Short.valueOf((short) 8), violations.get(0));
   
    // active txid w/ file
    m = new Mutation(new Text("0;foo"));
    m.put(TabletsSection.BulkFileColumnFamily.NAME, new Text("/someFile"), new Value("5".getBytes()));
    m.put(DataFileColumnFamily.NAME, new Text("/someFile"), new Value("1,1".getBytes()));
    violations = mc.check(null, m);
    assertNull(violations);
   
    // active txid w/o file
    m = new Mutation(new Text("0;foo"));
    m.put(TabletsSection.BulkFileColumnFamily.NAME, new Text("/someFile"), new Value("5".getBytes()));
    violations = mc.check(null, m);
    assertNotNull(violations);
    assertEquals(1, violations.size());
    assertEquals(Short.valueOf((short) 8), violations.get(0));
   
    // two active txids w/ files
    m = new Mutation(new Text("0;foo"));
    m.put(TabletsSection.BulkFileColumnFamily.NAME, new Text("/someFile"), new Value("5".getBytes()));
    m.put(DataFileColumnFamily.NAME, new Text("/someFile"), new Value("1,1".getBytes()));
    m.put(TabletsSection.BulkFileColumnFamily.NAME, new Text("/someFile2"), new Value("7".getBytes()));
    m.put(DataFileColumnFamily.NAME, new Text("/someFile2"), new Value("1,1".getBytes()));
    violations = mc.check(null, m);
    assertNotNull(violations);
    assertEquals(1, violations.size());
    assertEquals(Short.valueOf((short) 8), violations.get(0));
   
    // two files w/ one active txid
    m = new Mutation(new Text("0;foo"));
    m.put(TabletsSection.BulkFileColumnFamily.NAME, new Text("/someFile"), new Value("5".getBytes()));
    m.put(DataFileColumnFamily.NAME, new Text("/someFile"), new Value("1,1".getBytes()));
    m.put(TabletsSection.BulkFileColumnFamily.NAME, new Text("/someFile2"), new Value("5".getBytes()));
    m.put(DataFileColumnFamily.NAME, new Text("/someFile2"), new Value("1,1".getBytes()));
    violations = mc.check(null, m);
    assertNull(violations);
   
    // two loaded w/ one active txid and one file
    m = new Mutation(new Text("0;foo"));
    m.put(TabletsSection.BulkFileColumnFamily.NAME, new Text("/someFile"), new Value("5".getBytes()));
    m.put(DataFileColumnFamily.NAME, new Text("/someFile"), new Value("1,1".getBytes()));
    m.put(TabletsSection.BulkFileColumnFamily.NAME, new Text("/someFile2"), new Value("5".getBytes()));
    violations = mc.check(null, m);
    assertNotNull(violations);
    assertEquals(1, violations.size());
    assertEquals(Short.valueOf((short) 8), violations.get(0));
   
    // active txid, mutation that looks like split
    m = new Mutation(new Text("0;foo"));
    m.put(TabletsSection.BulkFileColumnFamily.NAME, new Text("/someFile"), new Value("5".getBytes()));
    TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(m, new Value("/t1".getBytes()));
    violations = mc.check(null, m);
    assertNull(violations);
   
    // inactive txid, mutation that looks like split
    m = new Mutation(new Text("0;foo"));
    m.put(TabletsSection.BulkFileColumnFamily.NAME, new Text("/someFile"), new Value("12345".getBytes()));
    TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(m, new Value("/t1".getBytes()));
    violations = mc.check(null, m);
    assertNull(violations);
   
    // active txid, mutation that looks like a load
    m = new Mutation(new Text("0;foo"));
    m.put(TabletsSection.BulkFileColumnFamily.NAME, new Text("/someFile"), new Value("5".getBytes()));
    m.put(TabletsSection.CurrentLocationColumnFamily.NAME, new Text("789"), new Value("127.0.0.1:9997".getBytes()));
    violations = mc.check(null, m);
    assertNull(violations);
   
    // inactive txid, mutation that looks like a load
    m = new Mutation(new Text("0;foo"));
    m.put(TabletsSection.BulkFileColumnFamily.NAME, new Text("/someFile"), new Value("12345".getBytes()));
    m.put(TabletsSection.CurrentLocationColumnFamily.NAME, new Text("789"), new Value("127.0.0.1:9997".getBytes()));
    violations = mc.check(null, m);
    assertNull(violations);
   
    // deleting a load flag
    m = new Mutation(new Text("0;foo"));
    m.putDelete(TabletsSection.BulkFileColumnFamily.NAME, new Text("/someFile"));
    violations = mc.check(null, m);
    assertNull(violations);
   
  }
View Full Code Here

  public void testCheck() {
    Logger.getLogger(AccumuloConfiguration.class).setLevel(Level.ERROR);
    Mutation m = new Mutation(new Text("0;foo"));
    ColumnFQ.put(m, Constants.METADATA_PREV_ROW_COLUMN, new Value("1foo".getBytes()));
   
    MetadataConstraints mc = new MetadataConstraints();
   
    List<Short> violations = mc.check(m);
   
    assertNotNull(violations);
    assertEquals(1, violations.size());
    assertEquals(Short.valueOf((short) 3), violations.get(0));
   
    m = new Mutation(new Text("0:foo"));
    ColumnFQ.put(m, Constants.METADATA_PREV_ROW_COLUMN, new Value("1poo".getBytes()));
   
    violations = mc.check(m);
   
    assertNotNull(violations);
    assertEquals(1, violations.size());
    assertEquals(Short.valueOf((short) 4), violations.get(0));
   
    m = new Mutation(new Text("0;foo"));
    m.put(new Text("bad_column_name"), new Text(""), new Value("e".getBytes()));
   
    violations = mc.check(m);
   
    assertNotNull(violations);
    assertEquals(1, violations.size());
    assertEquals(Short.valueOf((short) 2), violations.get(0));
   
    m = new Mutation(new Text("!!<"));
    ColumnFQ.put(m, Constants.METADATA_PREV_ROW_COLUMN, new Value("1poo".getBytes()));
   
    violations = mc.check(m);
   
    assertNotNull(violations);
    assertEquals(2, violations.size());
    assertEquals(Short.valueOf((short) 4), violations.get(0));
    assertEquals(Short.valueOf((short) 5), violations.get(1));
   
    m = new Mutation(new Text("0;foo"));
    ColumnFQ.put(m, Constants.METADATA_PREV_ROW_COLUMN, new Value("".getBytes()));
   
    violations = mc.check(m);
   
    assertNotNull(violations);
    assertEquals(1, violations.size());
    assertEquals(Short.valueOf((short) 6), violations.get(0));
   
    m = new Mutation(new Text("0;foo"));
    ColumnFQ.put(m, Constants.METADATA_PREV_ROW_COLUMN, new Value("bar".getBytes()));
   
    violations = mc.check(m);
   
    assertEquals(null, violations);
   
    m = new Mutation(new Text("!0<"));
    ColumnFQ.put(m, Constants.METADATA_PREV_ROW_COLUMN, new Value("bar".getBytes()));
   
    violations = mc.check(m);
   
    assertEquals(null, violations);
   
    m = new Mutation(new Text("!1<"));
    ColumnFQ.put(m, Constants.METADATA_PREV_ROW_COLUMN, new Value("bar".getBytes()));
   
    violations = mc.check(m);
   
    assertNotNull(violations);
    assertEquals(1, violations.size());
    assertEquals(Short.valueOf((short) 4), violations.get(0));
   
View Full Code Here

TOP

Related Classes of org.apache.accumulo.server.constraints.MetadataConstraints

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.