-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: I7c7aa8a2a90a66827c670b295bc26ee0b1b152e4
- Loading branch information
1 parent
a08a67b
commit 5aa0a63
Showing
15 changed files
with
332 additions
and
98 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import com.google.cloud.bigtable.admin.v2.BigtableInstanceAdminClient; | ||
import com.google.cloud.bigtable.admin.v2.models.AppProfile; | ||
import com.google.cloud.bigtable.admin.v2.models.UpdateAppProfileRequest; | ||
import com.google.cloud.bigtable.data.v2.BigtableDataClient; | ||
import com.google.cloud.bigtable.data.v2.BigtableDataSettings; | ||
import com.google.cloud.bigtable.data.v2.models.Query; | ||
import com.google.cloud.bigtable.data.v2.models.RowMutation; | ||
import com.google.cloud.bigtable.data.v2.models.TableId; | ||
import java.io.IOException; | ||
|
||
public class CookieDataBoost { | ||
private static final String PROJECT_ID = "google.com:cloud-bigtable-dev"; | ||
private static final String INSTANCE_ID = "igorbernstein-dev"; | ||
private static final String TABLE_ID = "table2"; | ||
private static final String APP_PROFILE_ID = "databoost-test"; | ||
private static final String CLUSTER_ID = "igorbernstein-dev-c0"; | ||
|
||
public static void main(String[] args) throws IOException { | ||
BigtableInstanceAdminClient adminClient = BigtableInstanceAdminClient.create(PROJECT_ID); | ||
// adminClient.createAppProfile( | ||
// CreateAppProfileRequest.of(INSTANCE_ID, APP_PROFILE_ID) | ||
// | ||
// .setIsolationPolicy(AppProfile.DataBoostIsolationReadOnlyPolicy.of(AppProfile.ComputeBillingOwner.HOST_PAYS)) | ||
// | ||
// .setRoutingPolicy(AppProfile.SingleClusterRoutingPolicy.of(CLUSTER_ID)) | ||
// ); | ||
adminClient.updateAppProfile( | ||
UpdateAppProfileRequest.of(INSTANCE_ID, APP_PROFILE_ID) | ||
.setIsolationPolicy( | ||
AppProfile.DataBoostIsolationReadOnlyPolicy.of( | ||
AppProfile.ComputeBillingOwner.HOST_PAYS)) | ||
.setRoutingPolicy(AppProfile.SingleClusterRoutingPolicy.of(CLUSTER_ID)) | ||
.setIgnoreWarnings(true)); | ||
|
||
BigtableDataClient client = | ||
BigtableDataClient.create( | ||
BigtableDataSettings.newBuilder() | ||
.setProjectId(PROJECT_ID) | ||
.setInstanceId(INSTANCE_ID) | ||
.setAppProfileId(APP_PROFILE_ID) | ||
.build()); | ||
client.readRows(Query.create(TABLE_ID).limit(1)).iterator().next(); | ||
adminClient.updateAppProfile( | ||
UpdateAppProfileRequest.of(INSTANCE_ID, APP_PROFILE_ID) | ||
.setIsolationPolicy(AppProfile.StandardIsolationPolicy.of(AppProfile.Priority.HIGH)) | ||
.setRoutingPolicy(AppProfile.SingleClusterRoutingPolicy.of(CLUSTER_ID)) | ||
.setIgnoreWarnings(true)); | ||
client.mutateRow(RowMutation.create(TableId.of(TABLE_ID), "some-row").deleteRow()); | ||
client.readRows(Query.create(TABLE_ID).limit(1)).iterator().next(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
.../src/main/java/com/google/cloud/bigtable/data/v2/stub/opt/UnaryOverStreamingCallable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.google.cloud.bigtable.data.v2.stub.opt; | ||
|
||
import com.google.api.core.AbstractApiFuture; | ||
import com.google.api.core.ApiFuture; | ||
import com.google.api.gax.rpc.ApiCallContext; | ||
import com.google.api.gax.rpc.ResponseObserver; | ||
import com.google.api.gax.rpc.ServerStreamingCallable; | ||
import com.google.api.gax.rpc.StreamController; | ||
import com.google.api.gax.rpc.UnaryCallable; | ||
|
||
public class UnaryOverStreamingCallable<ReqT, RespT> extends UnaryCallable<ReqT, RespT> { | ||
private final ServerStreamingCallable<ReqT, RespT> inner; | ||
|
||
public UnaryOverStreamingCallable(ServerStreamingCallable<ReqT, RespT> inner) { | ||
this.inner = inner; | ||
} | ||
|
||
@Override | ||
public ApiFuture<RespT> futureCall(ReqT request, ApiCallContext context) { | ||
UnaryFuture<RespT> future = new UnaryFuture<>(); | ||
inner.call(request, future.observer, context); | ||
return future; | ||
} | ||
|
||
private static class UnaryFuture<RespT> extends AbstractApiFuture<RespT> { | ||
private StreamController controller; | ||
|
||
private final ResponseObserver<RespT> observer = | ||
new ResponseObserver<RespT>() { | ||
@Override | ||
public void onStart(StreamController streamController) { | ||
UnaryFuture.this.controller = streamController; | ||
} | ||
|
||
@Override | ||
public void onResponse(RespT response) { | ||
UnaryFuture.this.set(response); | ||
} | ||
|
||
@Override | ||
public void onError(Throwable throwable) { | ||
UnaryFuture.this.setException(throwable); | ||
} | ||
|
||
@Override | ||
public void onComplete() { | ||
UnaryFuture.this.set(null); | ||
} | ||
}; | ||
|
||
@Override | ||
protected void interruptTask() { | ||
controller.cancel(); | ||
} | ||
} | ||
} |
Oops, something went wrong.