mirror of https://github.com/apache/jclouds.git
added Closeable to top-level Chef apis
This commit is contained in:
parent
962937602a
commit
8e881dceb1
|
@ -38,6 +38,7 @@ import org.jclouds.rest.annotations.BinderParam;
|
||||||
import org.jclouds.rest.annotations.SinceApiVersion;
|
import org.jclouds.rest.annotations.SinceApiVersion;
|
||||||
import org.jclouds.rest.binders.BindToJsonPayload;
|
import org.jclouds.rest.binders.BindToJsonPayload;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -51,7 +52,7 @@ import java.util.Set;
|
||||||
* @see ChefAsyncApi
|
* @see ChefAsyncApi
|
||||||
* @see <a href="TODO: insert URL of Chef documentation" />
|
* @see <a href="TODO: insert URL of Chef documentation" />
|
||||||
*/
|
*/
|
||||||
public interface ChefApi {
|
public interface ChefApi extends Closeable {
|
||||||
/**
|
/**
|
||||||
* Creates a new sandbox. It accepts a list of checksums as input and returns
|
* Creates a new sandbox. It accepts a list of checksums as input and returns
|
||||||
* the URLs against which to PUT files that need to be uploaded.
|
* the URLs against which to PUT files that need to be uploaded.
|
||||||
|
|
|
@ -82,6 +82,8 @@ import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -97,7 +99,7 @@ import java.util.Set;
|
||||||
@RequestFilters(SignedHeaderAuth.class)
|
@RequestFilters(SignedHeaderAuth.class)
|
||||||
@Headers(keys = "X-Chef-Version", values = "{" + Constants.PROPERTY_API_VERSION + "}")
|
@Headers(keys = "X-Chef-Version", values = "{" + Constants.PROPERTY_API_VERSION + "}")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public interface ChefAsyncApi {
|
public interface ChefAsyncApi extends Closeable {
|
||||||
public static final String VERSION = "0.10.8";
|
public static final String VERSION = "0.10.8";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,31 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.chef.test;
|
package org.jclouds.chef.test;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
|
||||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
|
||||||
import org.jclouds.Constants;
|
|
||||||
import org.jclouds.blobstore.LocalAsyncBlobStore;
|
|
||||||
import org.jclouds.blobstore.domain.Blob;
|
|
||||||
import org.jclouds.blobstore.domain.PageSet;
|
|
||||||
import org.jclouds.blobstore.domain.StorageMetadata;
|
|
||||||
import org.jclouds.chef.ChefAsyncApi;
|
|
||||||
import org.jclouds.chef.domain.*;
|
|
||||||
import org.jclouds.chef.options.CreateClientOptions;
|
|
||||||
import org.jclouds.chef.options.SearchOptions;
|
|
||||||
import org.jclouds.io.Payload;
|
|
||||||
import org.jclouds.util.Strings2;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Named;
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
import javax.ws.rs.PathParam;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.base.Throwables.propagate;
|
import static com.google.common.base.Throwables.propagate;
|
||||||
import static com.google.common.collect.Iterables.transform;
|
import static com.google.common.collect.Iterables.transform;
|
||||||
|
@ -50,6 +25,43 @@ import static com.google.common.collect.Sets.newLinkedHashSet;
|
||||||
import static com.google.common.util.concurrent.Futures.immediateFuture;
|
import static com.google.common.util.concurrent.Futures.immediateFuture;
|
||||||
import static com.google.common.util.concurrent.Futures.transform;
|
import static com.google.common.util.concurrent.Futures.transform;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.Constants;
|
||||||
|
import org.jclouds.blobstore.LocalAsyncBlobStore;
|
||||||
|
import org.jclouds.blobstore.domain.Blob;
|
||||||
|
import org.jclouds.blobstore.domain.PageSet;
|
||||||
|
import org.jclouds.blobstore.domain.StorageMetadata;
|
||||||
|
import org.jclouds.chef.ChefAsyncApi;
|
||||||
|
import org.jclouds.chef.domain.Client;
|
||||||
|
import org.jclouds.chef.domain.CookbookDefinition;
|
||||||
|
import org.jclouds.chef.domain.CookbookVersion;
|
||||||
|
import org.jclouds.chef.domain.DatabagItem;
|
||||||
|
import org.jclouds.chef.domain.Environment;
|
||||||
|
import org.jclouds.chef.domain.Node;
|
||||||
|
import org.jclouds.chef.domain.Resource;
|
||||||
|
import org.jclouds.chef.domain.Role;
|
||||||
|
import org.jclouds.chef.domain.Sandbox;
|
||||||
|
import org.jclouds.chef.domain.SearchResult;
|
||||||
|
import org.jclouds.chef.domain.UploadSandbox;
|
||||||
|
import org.jclouds.chef.options.CreateClientOptions;
|
||||||
|
import org.jclouds.chef.options.SearchOptions;
|
||||||
|
import org.jclouds.io.Payload;
|
||||||
|
import org.jclouds.lifecycle.Closer;
|
||||||
|
import org.jclouds.util.Strings2;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In-memory chef simulator.
|
* In-memory chef simulator.
|
||||||
*
|
*
|
||||||
|
@ -89,15 +101,17 @@ public class TransientChefAsyncApi implements ChefAsyncApi {
|
||||||
private final ListeningExecutorService userExecutor;
|
private final ListeningExecutorService userExecutor;
|
||||||
private final BlobToDatabagItem blobToDatabagItem;
|
private final BlobToDatabagItem blobToDatabagItem;
|
||||||
private final StorageMetadataToName storageMetadataToName;
|
private final StorageMetadataToName storageMetadataToName;
|
||||||
|
private final Closer closer;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
TransientChefAsyncApi(@Named("databags") LocalAsyncBlobStore databags, StorageMetadataToName storageMetadataToName,
|
TransientChefAsyncApi(@Named("databags") LocalAsyncBlobStore databags, StorageMetadataToName storageMetadataToName,
|
||||||
BlobToDatabagItem blobToDatabagItem,
|
BlobToDatabagItem blobToDatabagItem,
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
|
@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, Closer closer) {
|
||||||
this.databags = checkNotNull(databags, "databags");
|
this.databags = checkNotNull(databags, "databags");
|
||||||
this.storageMetadataToName = checkNotNull(storageMetadataToName, "storageMetadataToName");
|
this.storageMetadataToName = checkNotNull(storageMetadataToName, "storageMetadataToName");
|
||||||
this.blobToDatabagItem = checkNotNull(blobToDatabagItem, "blobToDatabagItem");
|
this.blobToDatabagItem = checkNotNull(blobToDatabagItem, "blobToDatabagItem");
|
||||||
this.userExecutor = checkNotNull(userExecutor, "userExecutor");
|
this.userExecutor = checkNotNull(userExecutor, "userExecutor");
|
||||||
|
this.closer = checkNotNull(closer, "closer");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -397,4 +411,9 @@ public class TransientChefAsyncApi implements ChefAsyncApi {
|
||||||
public ListenableFuture<? extends SearchResult<? extends Environment>> searchEnvironments(SearchOptions options) {
|
public ListenableFuture<? extends SearchResult<? extends Environment>> searchEnvironments(SearchOptions options) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
closer.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue