Skip to content

Commit

Permalink
Merge pull request opendistro-for-elasticsearch#10 from rupal-bq/benc…
Browse files Browse the repository at this point in the history
…hmarking

add cassandra database launcher
  • Loading branch information
rupal-bq authored Oct 28, 2020
2 parents 8876589 + d5d85c0 commit 81faaff
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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;

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);
}
}
Original file line number Diff line number Diff line change
@@ -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 {

}
Original file line number Diff line number Diff line change
@@ -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.");
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
@@ -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 {

}
}

0 comments on commit 81faaff

Please sign in to comment.