Skip to content

Commit 1e62880

Browse files
Merge pull request #1760 from krishnamoorthy-r/krishraj-dev
Add support for running YCSB with the experimental Host.
2 parents 58d5878 + d4004db commit 1e62880

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

cloudspanner/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ If you wish to load a large database, you can run YCSB on multiple client VMs in
8787
* Split the key range evenly between client VMs;
8888
* Use few threads on each client VM, so that each individual commit request contains keys which are (close to) consecutive, and would thus likely address a single split; this also helps avoid overloading the servers.
8989

90-
The idea is that we have a number of 'write heads' which are all writing to different parts of the database (and thus talking to different servers), but each individual head is writing its own data (more or less) in order. See the [best practices page](https://cloud.google.com/spanner/docs/best-practices#loading_data) for further details.
90+
The idea is that we have a number of 'write heads' which are all writing to different parts of the database (and thus talking to different servers), but each individual head is writing its own data (more or less) in order. See the [best practices page](https://cloud.google.com/spanner/docs/bulk-loading) for further details.
9191

9292
### 6. Run a Workload
9393

cloudspanner/src/main/java/site/ycsb/db/cloudspanner/CloudSpannerClient.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package site.ycsb.db.cloudspanner;
1818

1919
import com.google.common.base.Joiner;
20+
import com.google.cloud.NoCredentials;
2021
import com.google.cloud.spanner.DatabaseId;
2122
import com.google.cloud.spanner.DatabaseClient;
2223
import com.google.cloud.spanner.Key;
@@ -32,6 +33,7 @@
3233
import com.google.cloud.spanner.Struct;
3334
import com.google.cloud.spanner.StructReader;
3435
import com.google.cloud.spanner.TimestampBound;
36+
import io.grpc.ManagedChannelBuilder;
3537
import site.ycsb.ByteIterator;
3638
import site.ycsb.Client;
3739
import site.ycsb.DB;
@@ -100,6 +102,15 @@ private CloudSpannerProperties() {}
100102
* Number of Cloud Spanner client channels to use. It's recommended to leave this to be the default value.
101103
*/
102104
static final String NUM_CHANNELS = "cloudspanner.channels";
105+
/**
106+
* Use plain text for communication.
107+
*/
108+
static final String USE_PLAINTEXT = "cloudspanner.useplaintext";
109+
110+
/**
111+
* Connect to Experimental host instead of cloud spanner API.
112+
*/
113+
static final String EXPERIMENTAL_HOST="cloudspanner.experimentalhost";
103114
}
104115

105116
private static int fieldCount;
@@ -167,6 +178,18 @@ private static Spanner getSpanner(Properties properties, String host, String pro
167178
if (numChannels != null) {
168179
optionsBuilder.setNumChannels(Integer.parseInt(numChannels));
169180
}
181+
boolean usePlaintext = Boolean.parseBoolean(properties.getProperty(CloudSpannerProperties.USE_PLAINTEXT));
182+
if (usePlaintext) {
183+
optionsBuilder.setChannelConfigurator(ManagedChannelBuilder::usePlaintext);
184+
//Disable credentials and built in metrics when plaintext is used.
185+
optionsBuilder.setCredentials(NoCredentials.getInstance());
186+
optionsBuilder.setBuiltInMetricsEnabled(false);
187+
}
188+
String experimentalHost = properties.getProperty(CloudSpannerProperties.EXPERIMENTAL_HOST);
189+
if (experimentalHost != null) {
190+
optionsBuilder.setExperimentalHost(experimentalHost);
191+
}
192+
170193
spanner = optionsBuilder.build().getService();
171194
Runtime.getRuntime().addShutdownHook(new Thread("spannerShutdown") {
172195
@Override

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ LICENSE file.
118118
<azurecosmos.version>4.8.0</azurecosmos.version>
119119
<azurestorage.version>4.0.0</azurestorage.version>
120120
<cassandra.cql.version>3.0.0</cassandra.cql.version>
121-
<cloudspanner.version>6.71.0</cloudspanner.version>
121+
<cloudspanner.version>6.91.1</cloudspanner.version>
122122
<couchbase.version>1.4.10</couchbase.version>
123123
<couchbase2.version>2.3.1</couchbase2.version>
124124
<crail.version>1.1-incubating</crail.version>

0 commit comments

Comments
 (0)