Пример #1
0
  @Override
  public LoadedInstanceConfig storeConfig(ConfigCollection config, long compareVersion)
      throws Exception {
    {
      ObjectMetadata metadata = getConfigMetadata();
      if (metadata != null) {
        Date lastModified = metadata.getLastModified();
        if (lastModified.getTime() != compareVersion) {
          return null; // apparently there's no atomic way to do this with S3 so this will have to
                       // do
        }
      }
    }

    PropertyBasedInstanceConfig propertyBasedInstanceConfig =
        new PropertyBasedInstanceConfig(config);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    propertyBasedInstanceConfig
        .getProperties()
        .store(out, "Auto-generated by Exhibitor " + hostname);

    byte[] bytes = out.toByteArray();
    ObjectMetadata metadata =
        S3Utils.simpleUploadFile(s3Client, bytes, arguments.getBucket(), arguments.getKey());

    return new LoadedInstanceConfig(
        propertyBasedInstanceConfig, metadata.getLastModified().getTime());
  }