CPD Results

The following document contains the results of PMD's CPD 4.3.

Duplications

FileLine
org/apache/accumulo/server/master/balancer/ChaoticLoadBalancerTest.java113
org/apache/accumulo/server/master/balancer/DefaultLoadBalancerTest.java148
  }
  
  SortedMap<TServerInstance,TabletServerStatus> getAssignments(Map<TServerInstance,FakeTServer> servers) {
    SortedMap<TServerInstance,TabletServerStatus> result = new TreeMap<TServerInstance,TabletServerStatus>();
    for (Entry<TServerInstance,FakeTServer> entry : servers.entrySet()) {
      result.put(entry.getKey(), entry.getValue().getStatus(entry.getKey()));
    }
    return result;
  }
  
  @Test
  public void testUnevenAssignment() {
    servers.clear();
    for (char c : "abcdefghijklmnopqrstuvwxyz".toCharArray()) {
      String cString = Character.toString(c);
      InetSocketAddress fakeAddress = AddressUtil.parseAddress("127.0.0.1", (int) c);
      String fakeInstance = cString;
      TServerInstance tsi = new TServerInstance(fakeAddress, fakeInstance);
      FakeTServer fakeTServer = new FakeTServer();
      servers.put(tsi, fakeTServer);
      fakeTServer.extents.add(makeExtent(cString, null, null));
    }
    // Put more tablets on one server, but not more than the number of servers
    Entry<TServerInstance,FakeTServer> first = servers.entrySet().iterator().next();
    first.getValue().extents.add(makeExtent("newTable", "a", null));
    first.getValue().extents.add(makeExtent("newTable", "b", "a"));
    first.getValue().extents.add(makeExtent("newTable", "c", "b"));
    first.getValue().extents.add(makeExtent("newTable", "d", "c"));
    first.getValue().extents.add(makeExtent("newTable", "e", "d"));
    first.getValue().extents.add(makeExtent("newTable", "f", "e"));
    first.getValue().extents.add(makeExtent("newTable", "g", "f"));
    first.getValue().extents.add(makeExtent("newTable", "h", "g"));
    first.getValue().extents.add(makeExtent("newTable", "i", null));
FileLine
org/apache/accumulo/server/master/balancer/ChaoticLoadBalancerTest.java68
org/apache/accumulo/server/master/balancer/DefaultLoadBalancerTest.java69
  class TestChaoticLoadBalancer extends ChaoticLoadBalancer {
    
    @Override
    public List<TabletStats> getOnlineTabletsForTable(TServerInstance tserver, String table) throws ThriftSecurityException, TException {
      List<TabletStats> result = new ArrayList<TabletStats>();
      for (KeyExtent extent : servers.get(tserver).extents) {
        if (extent.getTableId().toString().equals(table)) {
          result.add(new TabletStats(extent.toThrift(), null, null, null, 0l, 0., 0., 0));
        }
      }
      return result;
    }
  }
  
  @Test
  public void testAssignMigrations() {
    servers.clear();
    servers.put(new TServerInstance(AddressUtil.parseAddress("127.0.0.1", 1234), "a"), new FakeTServer());
    servers.put(new TServerInstance(AddressUtil.parseAddress("127.0.0.1", 1235), "b"), new FakeTServer());
    servers.put(new TServerInstance(AddressUtil.parseAddress("127.0.0.1", 1236), "c"), new FakeTServer());
FileLine
org/apache/accumulo/server/tabletserver/log/SortedLogRecoveryTest.java219
org/apache/accumulo/server/tabletserver/log/SortedLogRecoveryTest.java503
  public void testCompactionCrossesLogs6() throws IOException {
    // Create a test log
    Mutation ignored = new ServerMutation(new Text("ignored"));
    ignored.put(cf, cq, value);
    Mutation m = new ServerMutation(new Text("row1"));
    m.put(cf, cq, value);
    Mutation m2 = new ServerMutation(new Text("row2"));
    m2.put(cf, cq, value);
    Mutation m3 = new ServerMutation(new Text("row3"));
    m3.put(cf, cq, value);
    Mutation m4 = new ServerMutation(new Text("row4"));
    m4.put(cf, cq, value);
    Mutation m5 = new ServerMutation(new Text("row5"));
    m5.put(cf, cq, value);
    KeyValue entries[] = new KeyValue[] {createKeyValue(OPEN, 0, 1, "2"), createKeyValue(DEFINE_TABLET, 1, 1, extent), createKeyValue(MUTATION, 1, 1, ignored),
FileLine
org/apache/accumulo/server/master/balancer/ChaoticLoadBalancerTest.java44
org/apache/accumulo/server/master/balancer/DefaultLoadBalancerTest.java45
public class ChaoticLoadBalancerTest {
  
  class FakeTServer {
    List<KeyExtent> extents = new ArrayList<KeyExtent>();
    
    TabletServerStatus getStatus(TServerInstance server) {
      TabletServerStatus result = new TabletServerStatus();
      result.tableMap = new HashMap<String,TableInfo>();
      for (KeyExtent extent : extents) {
        String table = extent.getTableId().toString();
        TableInfo info = result.tableMap.get(table);
        if (info == null)
          result.tableMap.put(table, info = new TableInfo());
        info.onlineTablets++;
        info.recs = info.onlineTablets;
        info.ingestRate = 123.;
        info.queryRate = 456.;
      }
      return result;
    }
  }
  
  Map<TServerInstance,FakeTServer> servers = new HashMap<TServerInstance,FakeTServer>();
  
  class TestChaoticLoadBalancer extends ChaoticLoadBalancer {
FileLine
org/apache/accumulo/server/util/CloneTest.java133
org/apache/accumulo/server/util/CloneTest.java249
    bw1.addMutation(createTablet("0", null, "m", "/t-1", "/default_tablet/0_0.rf"));
    
    bw1.flush();
    
    int rc = MetadataTable.checkClone("0", "1", conn, bw2);
    
    assertEquals(0, rc);
    
    Scanner scanner = conn.createScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS);
    scanner.setRange(new KeyExtent(new Text("1"), null, null).toMetadataRange());
    
    HashSet<String> files = new HashSet<String>();
    
    int count = 0;
    for (Entry<Key,Value> entry : scanner) {
      if (entry.getKey().getColumnFamily().equals(Constants.METADATA_DATAFILE_COLUMN_FAMILY)) {
        files.add(entry.getKey().getColumnQualifier().toString());
        count++;
      }
    }
    
    assertEquals(1, count);
FileLine
org/apache/accumulo/server/tabletserver/log/SortedLogRecoveryTest.java219
org/apache/accumulo/server/tabletserver/log/SortedLogRecoveryTest.java453
org/apache/accumulo/server/tabletserver/log/SortedLogRecoveryTest.java503
  public void testCompactionCrossesLogs6() throws IOException {
    // Create a test log
    Mutation ignored = new ServerMutation(new Text("ignored"));
    ignored.put(cf, cq, value);
    Mutation m = new ServerMutation(new Text("row1"));
    m.put(cf, cq, value);
    Mutation m2 = new ServerMutation(new Text("row2"));
    m2.put(cf, cq, value);
    Mutation m3 = new ServerMutation(new Text("row3"));
    m3.put(cf, cq, value);
    Mutation m4 = new ServerMutation(new Text("row4"));
    m4.put(cf, cq, value);
    Mutation m5 = new ServerMutation(new Text("row5"));
    m5.put(cf, cq, value);
FileLine
org/apache/accumulo/server/security/handler/ZKAuthorizor.java73
org/apache/accumulo/server/security/handler/ZKPermHandler.java223
  }
  
  @Override
  public void initializeSecurity(Credential itw, String rootuser) throws AccumuloSecurityException {
    IZooReaderWriter zoo = ZooReaderWriter.getRetryingInstance();
    
    // create the root user with all system privileges, no table privileges, and no record-level authorizations
    Set<SystemPermission> rootPerms = new TreeSet<SystemPermission>();
    for (SystemPermission p : SystemPermission.values())
      rootPerms.add(p);
    Map<String,Set<TablePermission>> tablePerms = new HashMap<String,Set<TablePermission>>();
    // Allow the root user to flush the !METADATA table
    tablePerms.put(Constants.METADATA_TABLE_ID, Collections.singleton(TablePermission.ALTER_TABLE));
    
    try {
      // prep parent node of users with root username
      if (!zoo.exists(ZKUserPath))
        zoo.putPersistentData(ZKUserPath, rootuser.getBytes(), NodeExistsPolicy.FAIL);
      
      initUser(rootuser);
      zoo.putPersistentData(ZKUserPath + "/" + rootuser + ZKUserAuths, ZKSecurityTool.convertAuthorizations(Constants.NO_AUTHS), NodeExistsPolicy.FAIL);
FileLine
org/apache/accumulo/server/util/CloneTest.java137
org/apache/accumulo/server/util/CloneTest.java185
    int rc = MetadataTable.checkClone("0", "1", conn, bw2);
    
    assertEquals(0, rc);
    
    Scanner scanner = conn.createScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS);
    scanner.setRange(new KeyExtent(new Text("1"), null, null).toMetadataRange());
    
    HashSet<String> files = new HashSet<String>();
    
    int count = 0;
    for (Entry<Key,Value> entry : scanner) {
      if (entry.getKey().getColumnFamily().equals(Constants.METADATA_DATAFILE_COLUMN_FAMILY)) {
        files.add(entry.getKey().getColumnQualifier().toString());
        count++;
      }
    }
    
    assertEquals(1, count);
FileLine
org/apache/accumulo/server/util/CloneTest.java183
org/apache/accumulo/server/util/CloneTest.java315
    assertEquals(1, rc);
    
    rc = MetadataTable.checkClone("0", "1", conn, bw2);
    
    assertEquals(0, rc);
    
    Scanner scanner = conn.createScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS);
    scanner.setRange(new KeyExtent(new Text("1"), null, null).toMetadataRange());
    
    HashSet<String> files = new HashSet<String>();
    
    int count = 0;
    
    for (Entry<Key,Value> entry : scanner) {
      if (entry.getKey().getColumnFamily().equals(Constants.METADATA_DATAFILE_COLUMN_FAMILY)) {
        files.add(entry.getKey().getColumnQualifier().toString());
        count++;
      }
    }
    
    assertEquals(1, files.size());
FileLine
org/apache/accumulo/server/util/CloneTest.java185
org/apache/accumulo/server/util/CloneTest.java253
    rc = MetadataTable.checkClone("0", "1", conn, bw2);
    
    assertEquals(0, rc);
    
    Scanner scanner = conn.createScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS);
    scanner.setRange(new KeyExtent(new Text("1"), null, null).toMetadataRange());
    
    HashSet<String> files = new HashSet<String>();
    
    int count = 0;
    
    for (Entry<Key,Value> entry : scanner) {
      if (entry.getKey().getColumnFamily().equals(Constants.METADATA_DATAFILE_COLUMN_FAMILY)) {
        files.add(entry.getKey().getColumnQualifier().toString());
        count++;
      }
    }
    
    assertEquals(1, files.size());
FileLine
org/apache/accumulo/server/util/CloneTest.java137
org/apache/accumulo/server/util/CloneTest.java317
    int rc = MetadataTable.checkClone("0", "1", conn, bw2);
    
    assertEquals(0, rc);
    
    Scanner scanner = conn.createScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS);
    scanner.setRange(new KeyExtent(new Text("1"), null, null).toMetadataRange());
    
    HashSet<String> files = new HashSet<String>();
    
    int count = 0;
    for (Entry<Key,Value> entry : scanner) {
      if (entry.getKey().getColumnFamily().equals(Constants.METADATA_DATAFILE_COLUMN_FAMILY)) {
        files.add(entry.getKey().getColumnQualifier().toString());
        count++;
      }
    }
    
    assertEquals(1, count);
FileLine
org/apache/accumulo/server/tabletserver/log/SortedLogRecoveryTest.java379
org/apache/accumulo/server/tabletserver/log/SortedLogRecoveryTest.java426
  public void testCompactionCrossesLogs2() throws IOException {
    // Create a test log
    Mutation ignored = new ServerMutation(new Text("ignored"));
    ignored.put(cf, cq, value);
    Mutation m = new ServerMutation(new Text("row1"));
    m.put(cf, cq, value);
    Mutation m2 = new ServerMutation(new Text("row2"));
    m2.put(cf, cq, value);
    Mutation m3 = new ServerMutation(new Text("row3"));
    m3.put(cf, cq, value);
    KeyValue entries[] = new KeyValue[] {createKeyValue(OPEN, 0, -1, "1"), createKeyValue(DEFINE_TABLET, 1, 1, extent),
        createKeyValue(COMPACTION_START, 3, 1, "somefile"), createKeyValue(MUTATION, 2, 1, ignored), createKeyValue(MUTATION, 4, 1, m),};
FileLine
org/apache/accumulo/server/util/CloneTest.java277
org/apache/accumulo/server/util/CloneTest.java342
  public void testClonedMarker() throws Exception {
    
    MockInstance mi = new MockInstance();
    Connector conn = mi.getConnector("", "");
    
    BatchWriter bw1 = conn.createBatchWriter(Constants.METADATA_TABLE_NAME, new BatchWriterConfig());
    
    bw1.addMutation(createTablet("0", "m", null, "/d1", "/d1/file1"));
    bw1.addMutation(createTablet("0", null, "m", "/d2", "/d2/file2"));
    
    bw1.flush();
    
    BatchWriter bw2 = conn.createBatchWriter(Constants.METADATA_TABLE_NAME, new BatchWriterConfig());
    
    MetadataTable.initializeClone("0", "1", conn, bw2);
    
    bw1.addMutation(deleteTablet("0", "m", null, "/d1", "/d1/file1"));
FileLine
org/apache/accumulo/server/master/balancer/DefaultLoadBalancerTest.java181
org/apache/accumulo/server/master/balancer/DefaultLoadBalancerTest.java225
    TestDefaultLoadBalancer balancer = new TestDefaultLoadBalancer();
    Set<KeyExtent> migrations = Collections.emptySet();
    int moved = 0;
    // balance until we can't balance no more!
    while (true) {
      List<TabletMigration> migrationsOut = new ArrayList<TabletMigration>();
      balancer.balance(getAssignments(servers), migrations, migrationsOut);
      if (migrationsOut.size() == 0)
        break;
      for (TabletMigration migration : migrationsOut) {
        if (servers.get(migration.oldServer).extents.remove(migration.tablet))
          moved++;
        servers.get(migration.newServer).extents.add(migration.tablet);
      }
    }
    assertEquals(8, moved);
FileLine
org/apache/accumulo/server/tabletserver/log/SortedLogRecoveryTest.java181
org/apache/accumulo/server/tabletserver/log/SortedLogRecoveryTest.java219
org/apache/accumulo/server/tabletserver/log/SortedLogRecoveryTest.java453
org/apache/accumulo/server/tabletserver/log/SortedLogRecoveryTest.java503
  public void testCompactionCrossesLogs5() throws IOException {
    // Create a test log
    Mutation ignored = new ServerMutation(new Text("ignored"));
    ignored.put(cf, cq, value);
    Mutation m = new ServerMutation(new Text("row1"));
    m.put(cf, cq, value);
    Mutation m2 = new ServerMutation(new Text("row2"));
    m2.put(cf, cq, value);
    Mutation m3 = new ServerMutation(new Text("row3"));
    m3.put(cf, cq, value);
    Mutation m4 = new ServerMutation(new Text("row4"));
    m4.put(cf, cq, value);
FileLine
org/apache/accumulo/server/tabletserver/log/SortedLogRecoveryTest.java333
org/apache/accumulo/server/tabletserver/log/SortedLogRecoveryTest.java357
  public void testGetMutationsAfterCompactionStart() throws IOException {
    // Create a test log
    Mutation ignored = new ServerMutation(new Text("ignored"));
    ignored.put(cf, cq, value);
    Mutation m = new ServerMutation(new Text("row1"));
    m.put(cf, cq, value);
    Mutation m2 = new ServerMutation(new Text("row2"));
    m2.put(cf, cq, new Value("123".getBytes()));
    KeyValue entries[] = new KeyValue[] {createKeyValue(OPEN, 0, -1, "1"), createKeyValue(DEFINE_TABLET, 1, 1, extent),
        createKeyValue(COMPACTION_START, 3, 1, "somefile"), createKeyValue(MUTATION, 2, 1, ignored), createKeyValue(MUTATION, 4, 1, m),};
FileLine
org/apache/accumulo/server/util/CloneTest.java231
org/apache/accumulo/server/util/CloneTest.java277
org/apache/accumulo/server/util/CloneTest.java342
  public void testSplit3() throws Exception {
    MockInstance mi = new MockInstance();
    Connector conn = mi.getConnector("", "");
    
    BatchWriter bw1 = conn.createBatchWriter(Constants.METADATA_TABLE_NAME, new BatchWriterConfig());
    
    bw1.addMutation(createTablet("0", "m", null, "/d1", "/d1/file1"));
    bw1.addMutation(createTablet("0", null, "m", "/d2", "/d2/file2"));
    
    bw1.flush();
    
    BatchWriter bw2 = conn.createBatchWriter(Constants.METADATA_TABLE_NAME, new BatchWriterConfig());
    
    MetadataTable.initializeClone("0", "1", conn, bw2);
    
    bw1.addMutation(createTablet("0", "f", null, "/d1", "/d1/file3"));
FileLine
org/apache/accumulo/server/tabletserver/log/SortedLogRecoveryTest.java340
org/apache/accumulo/server/tabletserver/log/SortedLogRecoveryTest.java388
    m2.put(cf, cq, new Value("123".getBytes()));
    KeyValue entries[] = new KeyValue[] {createKeyValue(OPEN, 0, -1, "1"), createKeyValue(DEFINE_TABLET, 1, 1, extent),
        createKeyValue(COMPACTION_START, 3, 1, "somefile"), createKeyValue(MUTATION, 2, 1, ignored), createKeyValue(MUTATION, 4, 1, m),};
    KeyValue entries2[] = new KeyValue[] {createKeyValue(OPEN, 5, -1, "1"), createKeyValue(DEFINE_TABLET, 6, 1, extent),
        createKeyValue(COMPACTION_FINISH, 7, 1, null), createKeyValue(MUTATION, 8, 1, m2),};
FileLine
org/apache/accumulo/server/util/CloneTest.java118
org/apache/accumulo/server/util/CloneTest.java160
  public void testSplit1() throws Exception {
    MockInstance mi = new MockInstance();
    Connector conn = mi.getConnector("", "");
    
    BatchWriter bw1 = conn.createBatchWriter(Constants.METADATA_TABLE_NAME, new BatchWriterConfig());
    
    bw1.addMutation(createTablet("0", null, null, "/default_tablet", "/default_tablet/0_0.rf"));
    
    bw1.flush();
    
    BatchWriter bw2 = conn.createBatchWriter(Constants.METADATA_TABLE_NAME, new BatchWriterConfig());
    
    MetadataTable.initializeClone("0", "1", conn, bw2);
    
    bw1.addMutation(createTablet("0", "m", null, "/default_tablet", "/default_tablet/0_0.rf"));