diff --git a/dataproc/pom.xml b/dataproc/pom.xml
index 5d4cfcc9603..c28c912b081 100644
--- a/dataproc/pom.xml
+++ b/dataproc/pom.xml
@@ -42,6 +42,7 @@
junit
junit
4.12
+ test
com.google.cloud
diff --git a/dataproc/src/main/java/CreateCluster.java b/dataproc/src/main/java/CreateCluster.java
index a5e5f4264a1..f68852e8e2e 100644
--- a/dataproc/src/main/java/CreateCluster.java
+++ b/dataproc/src/main/java/CreateCluster.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-// [START create_cluster]
+// [START dataproc_create_cluster]
import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.dataproc.v1.Cluster;
import com.google.cloud.dataproc.v1.ClusterConfig;
@@ -23,7 +23,6 @@
import com.google.cloud.dataproc.v1.ClusterOperationMetadata;
import com.google.cloud.dataproc.v1.InstanceGroupConfig;
import java.io.IOException;
-import java.io.InterruptedIOException;
import java.util.concurrent.ExecutionException;
public class CreateCluster {
@@ -60,12 +59,12 @@ public static void createCluster(String projectId, String region, String cluster
.setConfig(clusterConfig)
.build();
- // Send a request to create a Dataproc cluster.
+ // Create the Cloud Dataproc cluster
OperationFuture createClusterAsyncRequest =
clusterControllerClient.createClusterAsync(projectId, region, cluster);
Cluster response = createClusterAsyncRequest.get();
- // Print out the response
+ // Print out a success message
System.out.println(
String.format("Cluster created successfully: %s", response.getClusterName())
);
@@ -81,4 +80,4 @@ public static void createCluster(String projectId, String region, String cluster
}
}
}
-// [END create_cluster]
\ No newline at end of file
+// [END dataproc_create_cluster]
\ No newline at end of file
diff --git a/dataproc/src/test/java/CreateClusterTest.java b/dataproc/src/test/java/CreateClusterTest.java
index 39ab75f8233..800856b02dc 100644
--- a/dataproc/src/test/java/CreateClusterTest.java
+++ b/dataproc/src/test/java/CreateClusterTest.java
@@ -19,6 +19,7 @@
import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.dataproc.v1.ClusterControllerClient;
+import com.google.cloud.dataproc.v1.ClusterControllerSettings;
import com.google.cloud.dataproc.v1.ClusterOperationMetadata;
import com.google.protobuf.Empty;
import java.io.ByteArrayOutputStream;
@@ -75,8 +76,13 @@ public void createClusterTest() throws IOException, InterruptedException {
@After
public void tearDown() throws IOException, InterruptedException {
+ String myEndpoint = String.format("%s-dataproc.googleapis.com:443", REGION);
+
+ ClusterControllerSettings clusterControllerSettings =
+ ClusterControllerSettings.newBuilder().setEndpoint(myEndpoint).build();
+
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient
- .create()) {
+ .create(clusterControllerSettings)) {
OperationFuture deleteClusterAsyncRequest =
clusterControllerClient.deleteClusterAsync(projectId, REGION, clusterName);
deleteClusterAsyncRequest.get();