[
https://issues.apache.org/jira/browse/RYA-414?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16310177#comment-16310177
]
ASF GitHub Bot commented on RYA-414:
------------------------------------
Github user kchilton2 commented on a diff in the pull request:
https://github.com/apache/incubator-rya/pull/256#discussion_r159510270
--- Diff:
dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/dao/SimpleMongoDBNamespaceManager.java
---
@@ -37,147 +37,145 @@
public class SimpleMongoDBNamespaceManager implements
MongoDBNamespaceManager {
- public class NamespaceImplementation implements Namespace {
+ public class NamespaceImplementation implements Namespace {
- private final String namespace;
- private final String prefix;
+ private final String namespace;
+ private final String prefix;
- public NamespaceImplementation(final String namespace, final
String prefix) {
- this.namespace = namespace;
- this.prefix = prefix;
- }
+ public NamespaceImplementation(final String namespace, final
String prefix) {
+ this.namespace = namespace;
+ this.prefix = prefix;
+ }
- @Override
- public int compareTo(final Namespace o) {
- if (!namespace.equalsIgnoreCase(o.getName())) {
+ @Override
+ public int compareTo(final Namespace o) {
+ if (!namespace.equalsIgnoreCase(o.getName())) {
return namespace.compareTo(o.getName());
}
- if (!prefix.equalsIgnoreCase(o.getPrefix())) {
+ if (!prefix.equalsIgnoreCase(o.getPrefix())) {
return prefix.compareTo(o.getPrefix());
}
- return 0;
- }
-
- @Override
- public String getName() {
- return namespace;
- }
-
- @Override
- public String getPrefix() {
- return prefix;
- }
-
- }
-
- public class MongoCursorIteration implements
- CloseableIteration<Namespace, RyaDAOException> {
- private final DBCursor cursor;
-
- public MongoCursorIteration(final DBCursor cursor2) {
- this.cursor = cursor2;
- }
-
- @Override
- public boolean hasNext() throws RyaDAOException {
- return cursor.hasNext();
- }
-
- @Override
- public Namespace next() throws RyaDAOException {
- final DBObject ns = cursor.next();
- final Map values = ns.toMap();
- final String namespace = (String) values.get(NAMESPACE);
- final String prefix = (String) values.get(PREFIX);
-
- final Namespace temp = new
NamespaceImplementation(namespace, prefix);
- return temp;
- }
-
- @Override
- public void remove() throws RyaDAOException {
- next();
- }
-
- @Override
- public void close() throws RyaDAOException {
- cursor.close();
- }
-
- }
-
- private static final String ID = "_id";
- private static final String PREFIX = "prefix";
- private static final String NAMESPACE = "namespace";
- private MongoDBRdfConfiguration conf;
- private final DBCollection nsColl;
-
-
- public SimpleMongoDBNamespaceManager(final DBCollection
nameSpaceCollection) {
- nsColl = nameSpaceCollection;
- }
-
- @Override
- public void createIndices(final DBCollection coll){
- coll.createIndex(PREFIX);
- coll.createIndex(NAMESPACE);
- }
-
-
- @Override
- public void setConf(final MongoDBRdfConfiguration paramC) {
- this.conf = paramC;
- }
-
- @Override
- public MongoDBRdfConfiguration getConf() {
- // TODO Auto-generated method stub
- return conf;
- }
-
- @Override
- public void addNamespace(final String prefix, final String namespace)
- throws RyaDAOException {
- final String id = prefix;
- byte[] bytes = id.getBytes(StandardCharsets.UTF_8);
- try {
- final MessageDigest digest =
MessageDigest.getInstance("SHA-1");
- bytes = digest.digest(bytes);
- } catch (final NoSuchAlgorithmException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- final BasicDBObject doc = new BasicDBObject(ID, new
String(Hex.encodeHex(bytes)))
- .append(PREFIX, prefix)
- .append(NAMESPACE, namespace);
- nsColl.insert(doc);
-
- }
-
- @Override
- public String getNamespace(final String prefix) throws RyaDAOException {
+ return 0;
+ }
+
+ @Override
+ public String getName() {
+ return namespace;
+ }
+
+ @Override
+ public String getPrefix() {
+ return prefix;
+ }
+
+ }
+
+ public class MongoCursorIteration implements
+ CloseableIteration<Namespace, RyaDAOException> {
+ private final DBCursor cursor;
+
+ public MongoCursorIteration(final DBCursor cursor2) {
+ this.cursor = cursor2;
+ }
+
+ @Override
+ public boolean hasNext() throws RyaDAOException {
+ return cursor.hasNext();
+ }
+
+ @Override
+ public Namespace next() throws RyaDAOException {
+ final DBObject ns = cursor.next();
+ final Map values = ns.toMap();
+ final String namespace = (String) values.get(NAMESPACE);
+ final String prefix = (String) values.get(PREFIX);
+
+ final Namespace temp = new NamespaceImplementation(namespace,
prefix);
+ return temp;
+ }
+
+ @Override
+ public void remove() throws RyaDAOException {
+ next();
+ }
+
+ @Override
+ public void close() throws RyaDAOException {
+ cursor.close();
+ }
+
+ }
+
+ private static final String ID = "_id";
+ private static final String PREFIX = "prefix";
+ private static final String NAMESPACE = "namespace";
+ private StatefulMongoDBRdfConfiguration conf;
+ private final DBCollection nsColl;
+
+
+ public SimpleMongoDBNamespaceManager(final DBCollection
nameSpaceCollection) {
+ nsColl = nameSpaceCollection;
+ }
+
+ @Override
+ public void createIndices(final DBCollection coll){
+ coll.createIndex(PREFIX);
+ coll.createIndex(NAMESPACE);
+ }
+
+ @Override
+ public void setConf(final StatefulMongoDBRdfConfiguration conf) {
+ this.conf = conf;
+ }
+
+ @Override
+ public StatefulMongoDBRdfConfiguration getConf() {
+ return conf;
+ }
+
+ @Override
+ public void addNamespace(final String prefix, final String namespace)
+ throws RyaDAOException {
+ final String id = prefix;
+ byte[] bytes = id.getBytes(StandardCharsets.UTF_8);
+ try {
+ final MessageDigest digest =
MessageDigest.getInstance("SHA-1");
+ bytes = digest.digest(bytes);
+ } catch (final NoSuchAlgorithmException e) {
+ // TODO Auto-generated catch block
--- End diff --
Done.
> Fix inconsistent method of using MongoClient within a Sail object
> -----------------------------------------------------------------
>
> Key: RYA-414
> URL: https://issues.apache.org/jira/browse/RYA-414
> Project: Rya
> Issue Type: Bug
> Reporter: Andrew Smith
> Assignee: Kevin Chilton
> Priority: Blocker
>
> We've decided to introduce a stateful configuration object that is used to
> hold onto objects that needs to be shared across components within a Sail
> object in favor of having a static holder. The static holder limited our
> ability to use more than a single Sail object within a single JVM because all
> of those Sail objects would all have to access the same Mongo DB repository.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)