Exemplo n.º 1
0
 @Override
 protected void createRootDir() {
   try {
     swiftClient.createContainer(container);
   } catch (Exception e) {
     log.error("failure creating container", e);
   }
 }
Exemplo n.º 2
0
 @Override
 protected void remove(String clustername, Address addr) {
   String fileName = clustername + "/" + addressToFilename(addr);
   try {
     swiftClient.deleteObject(container, fileName);
   } catch (Exception e) {
     log.error("failure removing data", e);
   }
 }
Exemplo n.º 3
0
 @Override
 protected void write(List<PingData> list, String clustername) {
   try {
     String filename = clustername + "/" + addressToFilename(local_addr);
     ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
     write(list, out);
     byte[] data = out.toByteArray();
     swiftClient.createObject(container, filename, data);
   } catch (Exception e) {
     log.error("Error marshalling object", e);
   }
 }
Exemplo n.º 4
0
  @Override
  protected void readAll(List<Address> members, String clustername, Responses responses) {
    try {
      List<String> objects = swiftClient.listObjects(container);
      for (String object : objects) {
        List<PingData> list = null;
        byte[] bytes = swiftClient.readObject(container, object);
        if ((list = read(new ByteArrayInputStream(bytes))) == null) {
          log.warn("failed reading " + object);
          continue;
        }
        for (PingData data : list) {
          if (members == null || members.contains(data.getAddress()))
            responses.addResponse(data, data.isCoord());
          if (local_addr != null && !local_addr.equals(data.getAddress()))
            addDiscoveryResponseToCaches(
                data.getAddress(), data.getLogicalName(), data.getPhysicalAddr());
        }
      }

    } catch (Exception e) {
      log.error("Error unmarshalling object", e);
    }
  }
Exemplo n.º 5
0
  @Override
  public void init() throws Exception {
    Utils.validateNotEmpty(auth_url, "auth_url");
    Utils.validateNotEmpty(auth_type, "auth_type");
    Utils.validateNotEmpty(username, "username");
    Utils.validateNotEmpty(password, "password");
    Utils.validateNotEmpty(container, "container");

    Authenticator authenticator = createAuthenticator();
    authenticator.validateParams();

    swiftClient = new SwiftClient(authenticator);
    // Authenticate now to record credential
    swiftClient.authenticate();

    super.init();
  }