Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
E
evaluation-orchestrator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
8
Issues
8
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mowgli
evaluation-orchestrator
Commits
a7ee3ce9
Commit
a7ee3ce9
authored
Aug 20, 2019
by
Daniel Seybold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added command for getting cluster state for cassandra and couchbase
parent
de11c688
Pipeline
#54218
passed with stage
in 9 minutes and 52 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
12 deletions
+61
-12
src/main/java/de/uulm/omi/evaluation/task/RemoteCommand.java
src/main/java/de/uulm/omi/evaluation/task/RemoteCommand.java
+61
-12
No files found.
src/main/java/de/uulm/omi/evaluation/task/RemoteCommand.java
View file @
a7ee3ce9
...
...
@@ -62,10 +62,14 @@ public class RemoteCommand extends EvaluationTask {
String
seedEnpoint
=
endpoints
.
get
(
0
);
String
command
=
null
;
String
statusCommand
=
null
;
if
(
this
.
DBMSType
.
toLowerCase
().
equals
(
"cassandra"
)){
command
=
getCassandraCommand
();
command
=
getCassandraRecordCountCommand
();
statusCommand
=
getCassandraClusterStateCommand
();
}
else
if
(
this
.
DBMSType
.
toLowerCase
().
equals
(
"couchbase"
)){
command
=
getCouchbaseCommand
();
command
=
getCouchbaseRecordCountCommand
();
statusCommand
=
getCouchbaseClusterStateCommand
();
}
else
{
LOGGER
.
error
(
this
.
loggerPrefix
+
"Unsupported command target: "
+
this
.
DBMSType
+
"! Skipping RemoteCommand Task!"
);
return
new
DefaultWorkReport
(
WorkStatus
.
COMPLETED
);
...
...
@@ -98,16 +102,16 @@ public class RemoteCommand extends EvaluationTask {
JSch
jsch
=
new
JSch
();
String
user
=
"ubuntu"
;
//String host = "134.60.64.116";
int
port
=
22
;
//String privateKey = ".ssh/id_rsa";
final
String
user
=
"ubuntu"
;
final
int
port
=
22
;
try
{
jsch
.
addIdentity
(
"test_rsa"
,
privateKeyPlain
.
getBytes
(),
publicKeyPlain
.
getBytes
(),
"secret"
.
getBytes
());
/**
* get Records session
*/
Session
session
=
jsch
.
getSession
(
user
,
seedEnpoint
,
port
);
session
.
setConfig
(
"StrictHostKeyChecking"
,
"no"
);
LOGGER
.
debug
(
"session created."
);
...
...
@@ -130,7 +134,35 @@ public class RemoteCommand extends EvaluationTask {
/**
* Log the total number of records
*/
logNumberOfRecords
(
result
);
logCustomEntry
(
"CLUSTER_STATE"
,
result
);
/**
* get Cluster state session
*/
session
=
jsch
.
getSession
(
user
,
seedEnpoint
,
port
);
session
.
setConfig
(
"StrictHostKeyChecking"
,
"no"
);
LOGGER
.
debug
(
"session created."
);
session
.
connect
();
channel
=
(
ChannelExec
)
session
.
openChannel
(
"exec"
);
channel
.
setInputStream
(
null
);
output
=
channel
.
getInputStream
();
channel
.
setErrStream
(
System
.
err
);
channel
.
setCommand
(
command
);
channel
.
connect
();
String
clusterResult
=
CharStreams
.
toString
(
new
InputStreamReader
(
output
));
//printOutput(channel);
channel
.
disconnect
();
LOGGER
.
debug
(
this
.
loggerPrefix
+
"The remote result command is: "
+
clusterResult
);
/**
* Log the total number of records
*/
logCustomEntry
(
"CLUSTER_STATE"
,
clusterResult
);
}
catch
(
JSchException
e
)
{
LOGGER
.
error
(
e
.
getStackTrace
().
toString
());
...
...
@@ -145,13 +177,13 @@ public class RemoteCommand extends EvaluationTask {
return
new
DefaultWorkReport
(
WorkStatus
.
COMPLETED
);
}
private
void
log
NumberOfRecords
(
String
numberOfRecords
){
private
void
log
CustomEntry
(
String
id
,
String
value
){
long
currentTimestamp
=
System
.
currentTimeMillis
()/
1000
;
long
eventTimestamp
=
currentTimestamp
-
this
.
evaluationContext
.
getStartTime
();
String
taskLogMessage
=
new
SimpleDateFormat
(
"dd.MM.yyyy-HH:mm:ss"
).
format
(
new
Date
())
+
"; "
+
eventTimestamp
+
"s; "
+
"NUMBER_OF_RECORDS"
+
"; "
+
numberOfRecords
+
"\n"
;
String
taskLogMessage
=
new
SimpleDateFormat
(
"dd.MM.yyyy-HH:mm:ss"
).
format
(
new
Date
())
+
"; "
+
eventTimestamp
+
"s; "
+
id
+
"; "
+
value
+
"\n"
;
String
taskLogUri
=
this
.
evaluationContext
.
getEvluationRun
()
...
...
@@ -168,7 +200,7 @@ public class RemoteCommand extends EvaluationTask {
}
private
static
String
getCassandraCommand
(){
private
static
String
getCassandra
RecordCount
Command
(){
//TODO: check if these values need to be derived dynamically based on total number of records?
/**
...
...
@@ -186,9 +218,26 @@ public class RemoteCommand extends EvaluationTask {
return
command
;
}
private
static
String
getCouchbaseCommand
(){
private
static
String
getCassandraClusterStateCommand
(){
String
command
=
"source /etc/environment && sudo -E ./cassandra/bin/nodetool -h $LOCAL_ADDRESS status ycsb "
;
return
command
;
}
private
static
String
getCouchbaseRecordCountCommand
(){
String
commnad
=
"source /etc/environment && sudo -E curl -s http://$LOCAL_ADDRESS:8091/pools/default/buckets/ycsb/ -u ycsb:mowgli19 | jq '.basicStats | {itemCount: .itemCount }' | grep itemCount"
;
return
commnad
;
}
private
static
String
getCouchbaseClusterStateCommand
(){
String
command
=
"source /etc/environment && sudo -E /opt/couchbase/bin/couchbase-cli server-list -c $LOCAL_ADDRESS --username carlos --password mowgli19"
;
return
command
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment