Package com.alibaba.wasp

Examples of com.alibaba.wasp.EntityGroupInfo


      Result r = egR.get(egis.get(0));
      byte[] infoValue = r.getValue(FConstants.CATALOG_FAMILY,
          FConstants.EGINFO);
      byte[] locationValue = r.getValue(FConstants.CATALOG_FAMILY,
          FConstants.EGLOCATION);
      EntityGroupInfo key = EntityGroupInfo.parseFromOrNull(infoValue);
      ServerName value = ServerName.convert(locationValue);
      assertEquals(key.compareTo(egis.get(0)), 0);
      assertEquals(value.compareTo(egLocations[0]), 0);
    }

    // getTableEntityGroupsAndLocations
    List<Pair<EntityGroupInfo, ServerName>> entityGroupInfos = fMetaService
View Full Code Here


      for (Result r : results) {
        byte[] infoValue = r.getValue(FConstants.CATALOG_FAMILY,
            FConstants.EGINFO);
        byte[] locationValue = r.getValue(FConstants.CATALOG_FAMILY,
            FConstants.EGLOCATION);
        EntityGroupInfo key = EntityGroupInfo.parseFromOrNull(infoValue);
        ServerName value = ServerName.convert(locationValue);
        entityGroups.put(key, value);
      }
      for (int i = 0; i < egis.size(); i++) {
        ServerName sn = entityGroups.get(egis.get(i));
        assertEquals(sn.compareTo(egLocations[i]), 0);
      }

      // scanEntityGroupLocation
      byte[] row = Bytes.toBytes("20001");
      EntityGroupLocation egLocation = fMetaService.scanEntityGroupLocation(
          Bytes.toBytes(tableName), row);
      assertEquals(egLocation.getHostname(), egLocations[2].getHostname());
      assertEquals(egLocation.getPort(), egLocations[2].getPort());
      assertEquals(egLocation.getEntityGroupInfo().compareTo(egis.get(2)), 0);

      row = Bytes.toBytes(1);
      egLocation = fMetaService.scanEntityGroupLocation(
          Bytes.toBytes(tableName), row);
      assertEquals(egLocation.getHostname(), egLocations[0].getHostname());
      assertEquals(egLocation.getPort(), egLocations[0].getPort());
      assertEquals(egLocation.getEntityGroupInfo().compareTo(egis.get(0)), 0);

      List<EntityGroupLocation> egls = fMetaService
          .getEntityGroupLocations(Bytes.toBytes(tableName));
      assertEquals(egis.size(), egls.size());

      for (EntityGroupLocation egl : egls) {
        EntityGroupInfo eginfo = egl.getEntityGroupInfo();
        for (int i = 0; i < egis.size(); i++) {
          if (eginfo.compareTo(egis.get(i)) == 0) {
            assertEquals(egl.getHostname(), egLocations[i].getHostname());
            assertEquals(egl.getPort(), egLocations[i].getPort());
            break;
          }
        }
View Full Code Here

    fMetaService.addEntityGroup(egis);

    for (int i = 0; i < egis.size(); i++) {
      fMetaService.updateEntityGroupLocation(egis.get(i), egLocations[i]);
    }
    EntityGroupInfo egi = egis.get(1);
    assertFalse(egi.isOffline());
    egi.setOffline(true);
    fMetaService.modifyEntityGroupInfo(egi);

    EntityGroupInfo egi2 = fMetaService.getEntityGroupInfo(egi);
    assertEquals(egi.compareTo(egi2), 0);
    fMetaService.dropTable(FMetaTestUtil.User.getTableName());
  }
View Full Code Here

        Bytes.toBytes("20000"), Bytes.toBytes("30000"), Bytes.toBytes("40000"),
        Bytes.toBytes("50000"), Bytes.toBytes("60000"), Bytes.toBytes("70000"),
        Bytes.toBytes("80000"), Bytes.toBytes("90000"), null };
    List<EntityGroupInfo> egis = new ArrayList<EntityGroupInfo>();
    for (int i = 0; i < splitKeys.length - 2; i++) {
      EntityGroupInfo egi = new EntityGroupInfo(Bytes.toBytes(tableName),
          splitKeys[i], splitKeys[i + 1]);
      egis.add(egi);
    }
    return egis;
  }
View Full Code Here

    LinkedHashMap<String, Field> finalFields = new LinkedHashMap<String, Field>();
    for (Field field : fields) {
      finalFields.put(field.getName(), field);
    }
    table.setColumns(finalFields);
    EntityGroupInfo info = new EntityGroupInfo(Bytes.toBytes(table
        .getTableName()), startKey, stopKey, false);

    if (FMetaReader.exists(TEST_UTIL.getConfiguration(), info)) {
      throw new IOException("All ready has a entityGroupInfo "
          + info.getEntityGroupNameAsString());
    }
    return EntityGroup.openEntityGroup(info, table, conf, TEST_UTIL
        .getWaspCluster().getFServer(0), null);
  }
View Full Code Here

    LinkedHashMap<String, Field> finalFields = new LinkedHashMap<String, Field>();
    for (Field field : fields) {
      finalFields.put(field.getName(), field);
    }
    table.setColumns(finalFields);
    EntityGroupInfo info = new EntityGroupInfo(Bytes.toBytes(table
        .getTableName()), startKey, stopKey, false);

    if (FMetaReader.exists(TEST_UTIL.getConfiguration(), info)) {
      throw new IOException("All ready has a entityGroupInfo "
          + info.getEntityGroupNameAsString());
    }
    return EntityGroup.openEntityGroup(info, table, conf, TEST_UTIL
        .getWaspCluster().getFServer(0), null);
  }
View Full Code Here

        + "but only found " + entityGroups.size(), expectedEntityGroups,
        entityGroups.size());
    System.err.println("Found " + entityGroups.size() + " entityGroups");

    Iterator<EntityGroupInfo> egis = entityGroups.keySet().iterator();
    EntityGroupInfo egi = egis.next();
    assertTrue(egi.getStartKey() == null || egi.getStartKey().length == 0);
    assertTrue(Bytes.equals(egi.getEndKey(), splitKeys[0]));
    egi = egis.next();
    assertTrue(Bytes.equals(egi.getStartKey(), splitKeys[0]));
    assertTrue(Bytes.equals(egi.getEndKey(), splitKeys[1]));
    egi = egis.next();
    assertTrue(Bytes.equals(egi.getStartKey(), splitKeys[1]));
    assertTrue(Bytes.equals(egi.getEndKey(), splitKeys[2]));
    egi = egis.next();
    assertTrue(Bytes.equals(egi.getStartKey(), splitKeys[2]));
    assertTrue(Bytes.equals(egi.getEndKey(), splitKeys[3]));
    egi = egis.next();
    assertTrue(Bytes.equals(egi.getStartKey(), splitKeys[3]));
    assertTrue(Bytes.equals(egi.getEndKey(), splitKeys[4]));
    egi = egis.next();
    assertTrue(Bytes.equals(egi.getStartKey(), splitKeys[4]));
    assertTrue(Bytes.equals(egi.getEndKey(), splitKeys[5]));
    egi = egis.next();
    assertTrue(Bytes.equals(egi.getStartKey(), splitKeys[5]));
    assertTrue(Bytes.equals(egi.getEndKey(), splitKeys[6]));
    egi = egis.next();
    assertTrue(Bytes.equals(egi.getStartKey(), splitKeys[6]));
    assertTrue(Bytes.equals(egi.getEndKey(), splitKeys[7]));
    egi = egis.next();
    assertTrue(Bytes.equals(egi.getStartKey(), splitKeys[7]));
    assertTrue(Bytes.equals(egi.getEndKey(), splitKeys[8]));
    egi = egis.next();
    assertTrue(Bytes.equals(egi.getStartKey(), splitKeys[8]));
    assertTrue(egi.getEndKey() == null || egi.getEndKey().length == 0);

    // Now test using start/end with a number of entityGroups

    // Use 80 bit numbers to make sure we aren't limited
    byte[] startKey = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
    byte[] endKey = { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9 };

    // Splitting into 10 entityGroups, we expect (null,1) ... (9, null)
    // with (1,2) (2,3) (3,4) (4,5) (5,6) (6,7) (7,8) (8,9) in the middle

    expectedEntityGroups = 10;

    byte[] TABLE_2 = Bytes.add(tableName, Bytes.toBytes("_2"));

    desc = FMetaTestUtil.makeTable(Bytes.toString(TABLE_2));
    admin = new WaspAdmin(TEST_UTIL.getConfiguration());
    admin.createTable(desc, startKey, endKey, expectedEntityGroups);

    entityGroups = admin.getEntityGroupLocations(TABLE_2);
    assertEquals("Tried to create " + expectedEntityGroups + " entityGroups "
        + "but only found " + entityGroups.size(), expectedEntityGroups,
        entityGroups.size());
    System.err.println("Found " + entityGroups.size() + " entityGroups");

    egis = entityGroups.keySet().iterator();
    egi = egis.next();
    assertTrue(egi.getStartKey() == null || egi.getStartKey().length == 0);
    assertTrue(Bytes.equals(egi.getEndKey(), new byte[]{1, 1, 1, 1, 1, 1, 1,
        1, 1, 1}));
    egi = egis.next();
    assertTrue(Bytes.equals(egi.getStartKey(), new byte[]{1, 1, 1, 1, 1, 1,
        1, 1, 1, 1}));
    assertTrue(Bytes.equals(egi.getEndKey(), new byte[]{2, 2, 2, 2, 2, 2, 2,
        2, 2, 2}));
    egi = egis.next();
    assertTrue(Bytes.equals(egi.getStartKey(), new byte[]{2, 2, 2, 2, 2, 2,
        2, 2, 2, 2}));
    assertTrue(Bytes.equals(egi.getEndKey(), new byte[]{3, 3, 3, 3, 3, 3, 3,
        3, 3, 3}));
    egi = egis.next();
    assertTrue(Bytes.equals(egi.getStartKey(), new byte[]{3, 3, 3, 3, 3, 3,
        3, 3, 3, 3}));
    assertTrue(Bytes.equals(egi.getEndKey(), new byte[]{4, 4, 4, 4, 4, 4, 4,
        4, 4, 4}));
    egi = egis.next();
    assertTrue(Bytes.equals(egi.getStartKey(), new byte[]{4, 4, 4, 4, 4, 4,
        4, 4, 4, 4}));
    assertTrue(Bytes.equals(egi.getEndKey(), new byte[]{5, 5, 5, 5, 5, 5, 5,
        5, 5, 5}));
    egi = egis.next();
    assertTrue(Bytes.equals(egi.getStartKey(), new byte[]{5, 5, 5, 5, 5, 5,
        5, 5, 5, 5}));
    assertTrue(Bytes.equals(egi.getEndKey(), new byte[]{6, 6, 6, 6, 6, 6, 6,
        6, 6, 6}));
    egi = egis.next();
    assertTrue(Bytes.equals(egi.getStartKey(), new byte[]{6, 6, 6, 6, 6, 6,
        6, 6, 6, 6}));
    assertTrue(Bytes.equals(egi.getEndKey(), new byte[]{7, 7, 7, 7, 7, 7, 7,
        7, 7, 7}));
    egi = egis.next();
    assertTrue(Bytes.equals(egi.getStartKey(), new byte[]{7, 7, 7, 7, 7, 7,
        7, 7, 7, 7}));
    assertTrue(Bytes.equals(egi.getEndKey(), new byte[]{8, 8, 8, 8, 8, 8, 8,
        8, 8, 8}));
    egi = egis.next();
    assertTrue(Bytes.equals(egi.getStartKey(), new byte[]{8, 8, 8, 8, 8, 8,
        8, 8, 8, 8}));
    assertTrue(Bytes.equals(egi.getEndKey(), new byte[]{9, 9, 9, 9, 9, 9, 9,
        9, 9, 9}));
    egi = egis.next();
    assertTrue(Bytes.equals(egi.getStartKey(), new byte[]{9, 9, 9, 9, 9, 9,
        9, 9, 9, 9}));
    assertTrue(egi.getEndKey() == null || egi.getEndKey().length == 0);

    // Try once more with something that divides into something infinite

    startKey = new byte[] { 0, 0, 0, 0, 0, 0 };
    endKey = new byte[] { 1, 0, 0, 0, 0, 0 };
View Full Code Here

        entityGroups.add(entityGroupQueue.poll());
        continue;
      }
      Bytes.putInt(start, 0, numEntityGroups << 1);
      Bytes.putInt(end, 0, (numEntityGroups << 1) + 1);
      EntityGroupInfo egi = new EntityGroupInfo(Bytes.toBytes("table" + i),
          start, end, false, entityGroupId++);
      entityGroups.add(egi);
    }
    return entityGroups;
  }
View Full Code Here

      }

      if (LOG.isDebugEnabled()) {
        LOG.debug("rs=" + ctx + ", server=" + destination);
      }
      EntityGroupInfo entityGroup = ((EntityGroupState) ctx).getEntityGroup();
      offlineNodesVersions.put(entityGroup.getEncodedName(),
          Integer.valueOf(stat.getVersion()));
      this.counter.addAndGet(1);
    }
View Full Code Here

   * transition, log a warning and return null.
   */
  public synchronized EntityGroupState updateEntityGroupState(
      final EntityGroupTransaction transition, final EntityGroupState.State state) {
    byte[] entityGroupName = transition.getEntityGroupName();
    EntityGroupInfo entityGroupInfo = getEntityGroupInfo(entityGroupName);
    if (entityGroupInfo == null) {
      String prettyEntityGroupName = EntityGroupInfo
          .encodeEntityGroupName(entityGroupName);
      LOG.warn("Failed to find entityGroup " + prettyEntityGroupName
        + " in updating its state to " + state
View Full Code Here

TOP

Related Classes of com.alibaba.wasp.EntityGroupInfo

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.