From 6bf61060dac9ff7a8e37a6eec76d239f4a0a21a0 Mon Sep 17 00:00:00 2001 From: Rupal Mahajan <> Date: Tue, 27 Oct 2020 17:50:39 -0700 Subject: [PATCH 1/4] add cassandra database launcher --- .../cassandra/CassandraDatabaseLauncher.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/launch/cassandra/CassandraDatabaseLauncher.java diff --git a/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/launch/cassandra/CassandraDatabaseLauncher.java b/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/launch/cassandra/CassandraDatabaseLauncher.java new file mode 100644 index 0000000000..ba71c97f71 --- /dev/null +++ b/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/launch/cassandra/CassandraDatabaseLauncher.java @@ -0,0 +1,31 @@ +package com.amazon.opendistroforelasticsearch.sql.benchmark.utils.launch.cassandra; + +import static com.amazon.opendistroforelasticsearch.sql.benchmark.utils.CommandExecution.executeCommand; + +import com.amazon.opendistroforelasticsearch.sql.benchmark.utils.launch.DatabaseLauncher; +import java.io.IOException; + +public class CassandraDatabaseLauncher implements DatabaseLauncher { + + /** + * Function to launch an Cassandra database. + */ + @Override + public void launchDatabase(String systemPassword) throws IOException, InterruptedException { + String commands = "echo " + systemPassword + " | sudo -S " + + "update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java" + + " && echo " + systemPassword + " | sudo -S systemctl start cassandra.service" + + " && sudo systemctl status cassandra"; + executeCommand(commands); + } + + /** + * Function to shutdown an Cassandra database. + */ + @Override + public void shutdownDatabase(String systemPassword) throws IOException, InterruptedException { + String commands = "echo " + systemPassword + " | sudo -S systemctl stop cassandra.service" + + " && sudo systemctl status cassandra"; + executeCommand(commands); + } +} From be2b4358c60c970a00ff9a6febb0c43a8a324d7a Mon Sep 17 00:00:00 2001 From: Rupal Mahajan <> Date: Tue, 27 Oct 2020 17:52:12 -0700 Subject: [PATCH 2/4] add missing copyright --- .../cassandra/CassandraDatabaseLauncher.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/launch/cassandra/CassandraDatabaseLauncher.java b/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/launch/cassandra/CassandraDatabaseLauncher.java index ba71c97f71..2c0e5338ba 100644 --- a/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/launch/cassandra/CassandraDatabaseLauncher.java +++ b/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/launch/cassandra/CassandraDatabaseLauncher.java @@ -1,3 +1,18 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + package com.amazon.opendistroforelasticsearch.sql.benchmark.utils.launch.cassandra; import static com.amazon.opendistroforelasticsearch.sql.benchmark.utils.CommandExecution.executeCommand; From 779d1d125cd88510b636321c02172fd90dde14d0 Mon Sep 17 00:00:00 2001 From: Rupal Mahajan <> Date: Wed, 28 Oct 2020 10:00:03 -0700 Subject: [PATCH 3/4] cassandra classes --- .../load/cassandra/CassandraDataFormat.java | 25 ++++++++++ .../load/cassandra/CassandraDataLoader.java | 38 ++++++++++++++ .../cassandra/CassandraDataTransformer.java | 37 ++++++++++++++ .../query/cassandra/CassandraQueryRunner.java | 50 +++++++++++++++++++ 4 files changed, 150 insertions(+) create mode 100644 benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/load/cassandra/CassandraDataFormat.java create mode 100644 benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/load/cassandra/CassandraDataLoader.java create mode 100644 benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/load/cassandra/CassandraDataTransformer.java create mode 100644 benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/query/cassandra/CassandraQueryRunner.java diff --git a/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/load/cassandra/CassandraDataFormat.java b/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/load/cassandra/CassandraDataFormat.java new file mode 100644 index 0000000000..301a3b35e9 --- /dev/null +++ b/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/load/cassandra/CassandraDataFormat.java @@ -0,0 +1,25 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazon.opendistroforelasticsearch.sql.benchmark.utils.load.cassandra; + +import com.amazon.opendistroforelasticsearch.sql.benchmark.utils.load.DataFormat; + +/** + * Data format for Cassandra database. + */ +public class CassandraDataFormat extends DataFormat { + +} diff --git a/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/load/cassandra/CassandraDataLoader.java b/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/load/cassandra/CassandraDataLoader.java new file mode 100644 index 0000000000..39e52f6486 --- /dev/null +++ b/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/load/cassandra/CassandraDataLoader.java @@ -0,0 +1,38 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazon.opendistroforelasticsearch.sql.benchmark.utils.load.cassandra; + +import com.amazon.opendistroforelasticsearch.sql.benchmark.utils.load.DataFormat; +import com.amazon.opendistroforelasticsearch.sql.benchmark.utils.load.DataLoader; + +/** + * Data loader for Cassandra database. + */ +public class CassandraDataLoader implements DataLoader { + + /** + * Load function for Cassandra databases. + * + * @param data Data to load in CassandraDataFormat. + * @throws Exception Throws an Exception if data does not match expected type. + */ + @Override + public void loadData(DataFormat data) throws Exception { + if (!(data instanceof CassandraDataFormat)) { + throw new IllegalArgumentException("wrong data format for cassandra"); + } + } +} diff --git a/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/load/cassandra/CassandraDataTransformer.java b/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/load/cassandra/CassandraDataTransformer.java new file mode 100644 index 0000000000..f941932f50 --- /dev/null +++ b/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/load/cassandra/CassandraDataTransformer.java @@ -0,0 +1,37 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazon.opendistroforelasticsearch.sql.benchmark.utils.load.cassandra; + +import com.amazon.opendistroforelasticsearch.sql.benchmark.utils.load.DataFormat; +import com.amazon.opendistroforelasticsearch.sql.benchmark.utils.load.DataTransformer; + +/** + * Data transformer for Cassandra database. + */ +public class CassandraDataTransformer implements DataTransformer { + + /** + * Data transforming function for Cassandra. + * + * @param dataPath Directory for data to transform. + * @return Path to transformed data. + * @throws Exception Throws and exception if file read fails. + */ + @Override + public DataFormat transformData(String dataPath) throws Exception { + return null; + } +} diff --git a/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/query/cassandra/CassandraQueryRunner.java b/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/query/cassandra/CassandraQueryRunner.java new file mode 100644 index 0000000000..63b0580dc4 --- /dev/null +++ b/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/query/cassandra/CassandraQueryRunner.java @@ -0,0 +1,50 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazon.opendistroforelasticsearch.sql.benchmark.utils.query.cassandra; + +import com.amazon.opendistroforelasticsearch.sql.benchmark.utils.query.QueryRunner; + +/** + * Query runner for Cassandra databases. + */ +public class CassandraQueryRunner extends QueryRunner { + + /** + * Function to run queries against Cassandra database. + */ + @Override + public void runQuery() throws Exception { + + } + + /** + * Function to prepare query runner against Cassandra database. + * + * @param query Query to run against Cassandra database. + */ + @Override + public void prepareQueryRunner(String query) throws Exception { + + } + + /** + * Function to check query execution status against Cassandra database. + */ + @Override + public void checkQueryExecutionStatus(String benchmarkPath) throws Exception { + + } +} From d5d85c0cd08db1c39e71aadc0e6c0e53fe7e791f Mon Sep 17 00:00:00 2001 From: Rupal Mahajan <> Date: Wed, 28 Oct 2020 12:09:42 -0700 Subject: [PATCH 4/4] nit --- .../sql/benchmark/utils/load/cassandra/CassandraDataLoader.java | 2 +- .../utils/load/elasticsearch/ElasticsearchDataLoader.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/load/cassandra/CassandraDataLoader.java b/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/load/cassandra/CassandraDataLoader.java index 39e52f6486..013933de0e 100644 --- a/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/load/cassandra/CassandraDataLoader.java +++ b/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/load/cassandra/CassandraDataLoader.java @@ -32,7 +32,7 @@ public class CassandraDataLoader implements DataLoader { @Override public void loadData(DataFormat data) throws Exception { if (!(data instanceof CassandraDataFormat)) { - throw new IllegalArgumentException("wrong data format for cassandra"); + throw new IllegalArgumentException("Wrong data format for Cassandra."); } } } diff --git a/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/load/elasticsearch/ElasticsearchDataLoader.java b/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/load/elasticsearch/ElasticsearchDataLoader.java index e4f3384de8..66581934d1 100644 --- a/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/load/elasticsearch/ElasticsearchDataLoader.java +++ b/benchmark/src/main/java/com/amazon/opendistroforelasticsearch/sql/benchmark/utils/load/elasticsearch/ElasticsearchDataLoader.java @@ -36,7 +36,7 @@ public class ElasticsearchDataLoader implements DataLoader { @Override public void loadData(final DataFormat data) throws Exception { if (!(data instanceof ElasticsearchDataFormat)) { - throw new IllegalArgumentException("wrong data format for elasticsearch"); + throw new IllegalArgumentException("Wrong data format for Elasticsearch."); } String commands = "cd " + ((ElasticsearchDataFormat) data).getDataPath();