Exemplo n.º 1
0
  /* (non-Javadoc)
   * @see junit.framework.TestCase#setUp()
   */
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    System.out.println("TEST: " + getClass().getSimpleName());

    FSUtils.delTree(new java.io.File(SetupUtils.TEST_DIR));
  }
Exemplo n.º 2
0
  @BeforeClass
  public static void initializeTest() throws Exception {
    FSUtils.delTree(new java.io.File(SetupUtils.TEST_DIR));

    Logging.start(SetupUtils.DEBUG_LEVEL, SetupUtils.DEBUG_CATEGORIES);

    dirConfig = SetupUtils.createDIRConfig();
    dir = new DIRRequestDispatcher(dirConfig, SetupUtils.createDIRdbsConfig());
    dir.startup();
    dir.waitForStartup();

    testEnv =
        new TestEnvironment(
            new TestEnvironment.Services[] {
              TestEnvironment.Services.DIR_CLIENT,
              TestEnvironment.Services.TIME_SYNC,
              TestEnvironment.Services.RPC_CLIENT,
              TestEnvironment.Services.MRC
            });
    testEnv.start();

    userCredentials = UserCredentials.newBuilder().setUsername("test").addGroups("test").build();

    dirAddress = testEnv.getDIRAddress().getHostName() + ":" + testEnv.getDIRAddress().getPort();
    mrcAddress = testEnv.getMRCAddress().getHostName() + ":" + testEnv.getMRCAddress().getPort();

    defaultCoordinates =
        VivaldiCoordinates.newBuilder()
            .setXCoordinate(0)
            .setYCoordinate(0)
            .setLocalError(0)
            .build();
    defaultStripingPolicy =
        StripingPolicy.newBuilder()
            .setType(StripingPolicyType.STRIPING_POLICY_RAID0)
            .setStripeSize(128)
            .setWidth(1)
            .build();

    osds = new OSD[4];
    configs = SetupUtils.createMultipleOSDConfigs(4);

    // start three OSDs
    osds[0] = new OSD(configs[0]);
    osds[1] = new OSD(configs[1]);
    osds[2] = new OSD(configs[2]);
    osds[3] = new OSD(configs[3]);

    mrcClient = new MRCServiceClient(testEnv.getRpcClient(), null);

    options = new Options();
    client = ClientFactory.createClient(dirAddress, userCredentials, null, options);
    client.start();
  }
Exemplo n.º 3
0
  /* (non-Javadoc)
   * @see org.xtreemfs.babudb.api.dev.SnapshotManagerInternal#deleteAllSnapshots(java.lang.String)
   */
  @Override
  public void deleteAllSnapshots(String dbName) throws BabuDBException {

    final Map<String, Snapshot> snapMap = snapshotDBs.get(dbName);
    if (snapMap != null) {

      for (Entry<String, Snapshot> snap : snapMap.entrySet()) {

        // shut down the view
        snap.getValue().shutdown();

        // if a snapshot materialization request is currently in the
        // checkpointer queue, remove it
        dbs.getCheckpointer().removeSnapshotMaterializationRequest(dbName, snap.getKey());
      }

      // remove the map entry
      snapshotDBs.remove(dbName);
    }
    FSUtils.delTree(new File(getSnapshotDir(dbName, null)));

    // no delete log entries for the snapshots are needed here, since the
    // method will only be invoked when the database itself is deleted
  }
Exemplo n.º 4
0
 @Before
 public void setUp() throws Exception {
   FSUtils.delTree(testDir);
   testDir.mkdirs();
 }
Exemplo n.º 5
0
  public void start() throws Exception {
    try {
      // ensure that TEST_DIR is empty
      File testDir = new File(SetupUtils.TEST_DIR);
      FSUtils.delTree(testDir);
      testDir.mkdirs();

      rpcClient = SetupUtils.createRPCClient(10000);
      getRpcClient().start();
      getRpcClient().waitForStartup();

      dirClient = SetupUtils.createDIRClient(getRpcClient());

      if (enabledServs.contains(Services.DIR_SERVICE)) {
        dirService =
            new DIRRequestDispatcher(SetupUtils.createDIRConfig(), SetupUtils.createDIRdbsConfig());
        dirService.startup();
        dirService.waitForStartup();
        Logging.logMessage(Logging.LEVEL_DEBUG, this, "DIR running");
      }

      if (enabledServs.contains(Services.TIME_SYNC) || enabledServs.contains(Services.MOCKUP_OSD)) {
        tsInstance = TimeSync.initializeLocal(50);
        tsInstance.waitForStartup();
      }

      if (enabledServs.contains(Services.UUID_RESOLVER)) {
        DIRClient dc =
            new DIRClient(dirClient, new InetSocketAddress[] {getDIRAddress()}, 10, 1000 * 5);
        UUIDResolver.start(dc, 1000, 10 * 10 * 1000);
        SetupUtils.localResolver();
      }

      if (enabledServs.contains(Services.MOCKUP_OSD)) {
        Map<String, String> dmap = new HashMap();
        dmap.put("free", "1000000000");
        dmap.put("total", "1000000000");
        dmap.put("load", "0");
        dmap.put("totalRAM", "1000000000");
        dmap.put("usedRAM", "0");
        dmap.put("proto_version", "" + OSDServiceConstants.INTERFACE_ID);
        Service reg =
            Service.newBuilder()
                .setType(ServiceType.SERVICE_TYPE_OSD)
                .setName("mockUpOSD")
                .setUuid("mockUpOSD")
                .setVersion(0)
                .setLastUpdatedS(0)
                .setData(ServiceDataMap.newBuilder().addAllData(KeyValuePairs.fromMap(dmap)))
                .build();
        RPCResponse<serviceRegisterResponse> response =
            dirClient.xtreemfs_service_register(
                null, RPCAuthentication.authNone, RPCAuthentication.userService, reg);
        response.get();
        response.freeBuffers();

        UUIDResolver.addLocalMapping("mockUpOSD", 11111, Schemes.SCHEME_PBRPC);
      }

      if (enabledServs.contains(Services.MOCKUP_OSD2)) {
        Map<String, String> dmap = new HashMap();
        dmap.put("free", "1000000000");
        dmap.put("total", "1000000000");
        dmap.put("load", "0");
        dmap.put("totalRAM", "1000000000");
        dmap.put("usedRAM", "0");
        dmap.put("proto_version", "" + OSDServiceConstants.INTERFACE_ID);
        Service reg =
            Service.newBuilder()
                .setType(ServiceType.SERVICE_TYPE_OSD)
                .setName("mockUpOSD2")
                .setUuid("mockUpOSD2")
                .setVersion(0)
                .setLastUpdatedS(0)
                .setData(ServiceDataMap.newBuilder().addAllData(KeyValuePairs.fromMap(dmap)))
                .build();
        RPCResponse<serviceRegisterResponse> response =
            dirClient.xtreemfs_service_register(
                null, RPCAuthentication.authNone, RPCAuthentication.userService, reg);
        response.get();
        response.freeBuffers();

        UUIDResolver.addLocalMapping("mockUpOSD2", 11111, Schemes.SCHEME_PBRPC);
      }

      if (enabledServs.contains(Services.MOCKUP_OSD3)) {
        Map<String, String> dmap = new HashMap();
        dmap.put("free", "1000000000");
        dmap.put("total", "1000000000");
        dmap.put("load", "0");
        dmap.put("totalRAM", "1000000000");
        dmap.put("usedRAM", "0");
        dmap.put("proto_version", "" + OSDServiceConstants.INTERFACE_ID);
        Service reg =
            Service.newBuilder()
                .setType(ServiceType.SERVICE_TYPE_OSD)
                .setName("mockUpOSD3")
                .setUuid("mockUpOSD3")
                .setVersion(0)
                .setLastUpdatedS(0)
                .setData(ServiceDataMap.newBuilder().addAllData(KeyValuePairs.fromMap(dmap)))
                .build();
        RPCResponse<serviceRegisterResponse> response =
            dirClient.xtreemfs_service_register(
                null, RPCAuthentication.authNone, RPCAuthentication.userService, reg);
        response.get();
        response.freeBuffers();

        UUIDResolver.addLocalMapping("mockUpOSD3", 11111, Schemes.SCHEME_PBRPC);
      }

      if (enabledServs.contains(Services.OSD)) {
        int osdCount = Collections.frequency(enabledServs, Services.OSD);
        osds = new HashMap<String, TestOSD>(osdCount);
        osdConfigs = SetupUtils.createMultipleOSDConfigs(osdCount);
        for (OSDConfig config : osdConfigs) {
          TestOSD osd = new TestOSD(new OSDRequestDispatcher(config));
          osd.start();
          osds.put(config.getUUID().toString(), osd);
        }

        // Save address of first OSD for getOSDAdress method.
        firstOSDAddress = osdConfigs[0].getUUID().getAddress();

        Logging.logMessage(Logging.LEVEL_DEBUG, this, "OSDs 1-" + osdCount + " running");
      }

      if (enabledServs.contains(Services.MRC)) {
        mrc =
            new MRCRequestDispatcher(
                SetupUtils.createMRC1Config(), SetupUtils.createMRC1dbsConfig());
        mrc.startup();
        Logging.logMessage(Logging.LEVEL_DEBUG, this, "MRC running");
      }

      if (enabledServs.contains(Services.MRC_CLIENT)) {
        mrcClient = new MRCServiceClient(rpcClient, null);
      }

      if (enabledServs.contains(Services.OSD_CLIENT)) {
        osdClient = new OSDServiceClient(rpcClient, null);
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      // Shutdown servers which were already started or they will block ports.
      shutdown();

      // After shutdown, log remaining threads in case of blocked ports to debug the issue.
      if (ex instanceof BindException && ex.getMessage().contains("Address already in use")) {
        Logging.logMessage(
            Logging.LEVEL_ERROR,
            this,
            "TestEnvironment could not be started because: "
                + ex.getMessage()
                + " Please examine the following dump of threads to check if a previous test method did not correctly stop all servers.");
        StringBuilder threadStates = new StringBuilder();
        CrashReporter.reportThreadStates(threadStates);
        Logging.logMessage(Logging.LEVEL_ERROR, this, "Thread States: %s", threadStates.toString());
      }

      throw ex;
    }
  }