Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Y
YCSB
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Adnan Ahmad
YCSB
Commits
6ea36c12
Commit
6ea36c12
authored
10 years ago
by
Robert J. Moore
Browse files
Options
Downloads
Patches
Plain Diff
Add the avoidance of finalizers for cursors back in.
parent
3b9e207c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mongodb/src/main/java/com/yahoo/ycsb/db/OptionsSupport.java
+126
-0
126 additions, 0 deletions
mongodb/src/main/java/com/yahoo/ycsb/db/OptionsSupport.java
with
126 additions
and
0 deletions
mongodb/src/main/java/com/yahoo/ycsb/db/OptionsSupport.java
0 → 100644
+
126
−
0
View file @
6ea36c12
/*
* #%L
* OptionsSupport.java - mongodb-binding - Yahoo!, Inc.
* %%
* Copyright (C) 2015 Yahoo!, Inc.
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License 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.
* #L%
*/
package
com.yahoo.ycsb.db
;
import
java.util.Properties
;
/**
* OptionsSupport provides methods for handling legacy options.
*/
public
final
class
OptionsSupport
{
public
static
String
updateUrl
(
String
url
,
Properties
props
)
{
String
result
=
url
;
// max connections.
final
String
maxConnections
=
props
.
getProperty
(
"mongodb.maxconnections"
,
"N/A"
);
if
(!
"N/A"
.
equals
(
maxConnections
))
{
result
=
addUrlOption
(
result
,
"maxPoolSize"
,
maxConnections
);
}
// Blocked thread multiplier.
final
String
threadsAllowedToBlockForConnectionMultiplier
=
props
.
getProperty
(
"mongodb.threadsAllowedToBlockForConnectionMultiplier"
,
"N/A"
);
if
(!
"N/A"
.
equals
(
threadsAllowedToBlockForConnectionMultiplier
))
{
result
=
addUrlOption
(
result
,
"waitQueueMultiple"
,
threadsAllowedToBlockForConnectionMultiplier
);
}
// write concern
String
writeConcernType
=
props
.
getProperty
(
"mongodb.writeConcern"
,
"N/A"
).
toLowerCase
();
if
(!
"N/A"
.
equals
(
writeConcernType
))
{
if
(
"errors_ignored"
.
equals
(
writeConcernType
))
{
result
=
addUrlOption
(
result
,
"w"
,
"0"
);
}
else
if
(
"unacknowledged"
.
equals
(
writeConcernType
))
{
result
=
addUrlOption
(
result
,
"w"
,
"0"
);
}
else
if
(
"acknowledged"
.
equals
(
writeConcernType
))
{
result
=
addUrlOption
(
result
,
"w"
,
"1"
);
}
else
if
(
"journaled"
.
equals
(
writeConcernType
))
{
result
=
addUrlOption
(
result
,
"journal"
,
"true"
);
}
else
if
(
"replica_acknowledged"
.
equals
(
writeConcernType
))
{
result
=
addUrlOption
(
result
,
"w"
,
"2"
);
}
else
{
System
.
err
.
println
(
"WARNING: Invalid writeConcern: '"
+
writeConcernType
+
"' will be ignored."
);
}
}
// read preference
String
readPreferenceType
=
props
.
getProperty
(
"mongodb.writeConcern"
,
"N/A"
).
toLowerCase
();
if
(!
"N/A"
.
equals
(
readPreferenceType
))
{
if
(
"primary"
.
equals
(
readPreferenceType
))
{
result
=
addUrlOption
(
result
,
"readPreference"
,
"primary"
);
}
else
if
(
"primary_preferred"
.
equals
(
readPreferenceType
))
{
result
=
addUrlOption
(
result
,
"readPreference"
,
"primaryPreferred"
);
}
else
if
(
"secondary"
.
equals
(
readPreferenceType
))
{
result
=
addUrlOption
(
result
,
"readPreference"
,
"secondary"
);
}
else
if
(
"secondary_preferred"
.
equals
(
readPreferenceType
))
{
result
=
addUrlOption
(
result
,
"readPreference"
,
"secondaryPreferred"
);
}
else
if
(
"nearest"
.
equals
(
readPreferenceType
))
{
result
=
addUrlOption
(
result
,
"readPreference"
,
"nearest"
);
}
else
{
System
.
err
.
println
(
"WARNING: Invalid readPreference: '"
+
readPreferenceType
+
"' will be ignored."
);
}
}
return
result
;
}
/**
* Adds an option to the url if it does not already contain the option.
*
* @param url
* The URL to append the options to.
* @param name
* The name of the option.
* @param value
* The value for the option.
* @return The updated URL.
*/
private
static
String
addUrlOption
(
String
url
,
String
name
,
String
value
)
{
String
fullName
=
name
+
"="
;
if
(!
url
.
contains
(
fullName
))
{
if
(
url
.
contains
(
"?"
))
{
return
url
+
"&"
+
fullName
+
value
;
}
return
url
+
"?"
+
fullName
+
value
;
}
return
url
;
}
}
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