Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
JAliEn
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
JAliEn
JAliEn
Commits
ee97025e
Commit
ee97025e
authored
7 years ago
by
Miguel Martinez Pedreira
Browse files
Options
Downloads
Patches
Plain Diff
One more fix
parent
4c917a75
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/alien/test/cassandra/DBCassandra.java
+35
-31
35 additions, 31 deletions
src/alien/test/cassandra/DBCassandra.java
with
35 additions
and
31 deletions
src/alien/test/cassandra/DBCassandra.java
+
35
−
31
View file @
ee97025e
...
@@ -28,46 +28,49 @@ public class DBCassandra {
...
@@ -28,46 +28,49 @@ public class DBCassandra {
}
}
private
synchronized
static
void
createInstance
()
{
private
synchronized
static
void
createInstance
()
{
if
(
dbc
==
null
)
if
(
dbc
==
null
)
{
dbc
=
new
DBCassandra
();
dbc
=
new
DBCassandra
();
// Create the connection pool
System
.
out
.
println
(
"INSIDE CREATEINSTANCE: "
+
dbc
.
toString
());
final
PoolingOptions
poolingOptions
=
new
PoolingOptions
();
poolingOptions
.
setConnectionsPerHost
(
HostDistance
.
LOCAL
,
56
,
56
).
setConnectionsPerHost
(
HostDistance
.
REMOTE
,
56
,
56
);
// SocketOptions socketOptions = new SocketOptions();
// Create the connection pool
// socketOptions.setReadTimeoutMillis(12000);
final
PoolingOptions
poolingOptions
=
new
PoolingOptions
();
ExtProperties
config
=
ConfigUtils
.
getConfiguration
(
"cassandra"
);
poolingOptions
.
setConnectionsPerHost
(
HostDistance
.
LOCAL
,
56
,
56
).
setConnectionsPerHost
(
HostDistance
.
REMOTE
,
56
,
56
);
if
(
config
==
null
)
{
logger
.
severe
(
"cassandra.properties missing?"
);
return
;
}
String
nodes
=
config
.
gets
(
"cassandraNodes"
);
// SocketOptions socketOptions = new SocketOptions();
String
user
=
config
.
gets
(
"cassandraUsername"
);
// socketOptions.setReadTimeoutMillis(12000);
String
pass
=
config
.
gets
(
"cassandraPassword"
);
ExtProperties
config
=
ConfigUtils
.
getConfiguration
(
"cassandra"
);
if
(
config
==
null
)
{
logger
.
severe
(
"cassandra.properties missing?"
);
return
;
}
if
(
nodes
.
equals
(
""
)
||
user
.
equals
(
""
)
||
pass
.
equals
(
""
))
{
String
nodes
=
config
.
gets
(
"cassandraNodes"
);
logger
.
severe
(
"cassandra.properties misses some field: cassandraNodes or cassandraUsername or cassandraPassword"
);
String
user
=
config
.
gets
(
"cassandraUsername"
);
return
;
String
pass
=
config
.
gets
(
"cassandraPassword"
);
}
String
[]
ns
=
nodes
.
split
(
","
);
if
(
nodes
.
equals
(
""
)
||
user
.
equals
(
""
)
||
pass
.
equals
(
""
))
{
String
[]
addresses
=
new
String
[
ns
.
length
];
logger
.
severe
(
"cassandra.properties misses some field: cassandraNodes or cassandraUsername or cassandraPassword"
);
for
(
int
i
=
0
;
i
<
ns
.
length
;
i
++)
{
return
;
try
{
addresses
[
i
]
=
InetAddress
.
getByName
(
ns
[
i
]).
getHostAddress
();
logger
.
info
(
"Node address["
+
i
+
"]: "
+
addresses
[
i
]);
}
catch
(
UnknownHostException
e
)
{
logger
.
severe
(
"Cannot create InetAddress from: "
+
ns
[
i
]
+
" - Exception: "
+
e
);
}
}
}
DBCassandra
.
cluster
=
Cluster
.
builder
().
addContactPoints
(
addresses
).
withLoadBalancingPolicy
(
new
TokenAwarePolicy
(
new
RoundRobinPolicy
())).
withPoolingOptions
(
poolingOptions
)
String
[]
ns
=
nodes
.
split
(
","
);
// .withSocketOptions(socketOptions)
String
[]
addresses
=
new
String
[
ns
.
length
];
.
withCredentials
(
user
,
pass
).
build
();
for
(
int
i
=
0
;
i
<
ns
.
length
;
i
++)
{
try
{
addresses
[
i
]
=
InetAddress
.
getByName
(
ns
[
i
]).
getHostAddress
();
logger
.
info
(
"Node address["
+
i
+
"]: "
+
addresses
[
i
]);
}
catch
(
UnknownHostException
e
)
{
logger
.
severe
(
"Cannot create InetAddress from: "
+
ns
[
i
]
+
" - Exception: "
+
e
);
}
}
DBCassandra
.
cluster
=
Cluster
.
builder
().
addContactPoints
(
addresses
).
withLoadBalancingPolicy
(
new
TokenAwarePolicy
(
new
RoundRobinPolicy
())).
withPoolingOptions
(
poolingOptions
)
// .withSocketOptions(socketOptions)
.
withCredentials
(
user
,
pass
).
build
();
DBCassandra
.
session
=
cluster
.
connect
();
DBCassandra
.
session
=
cluster
.
connect
();
}
}
}
/**
/**
...
@@ -94,4 +97,5 @@ public class DBCassandra {
...
@@ -94,4 +97,5 @@ public class DBCassandra {
public
Object
clone
()
throws
CloneNotSupportedException
{
public
Object
clone
()
throws
CloneNotSupportedException
{
throw
new
CloneNotSupportedException
();
throw
new
CloneNotSupportedException
();
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment