Repository: asterixdb
Updated Branches:
refs/heads/master 6868d7da9 -> d90723359
[ASTERIXDB-2207][CLUS] Introduce Coordination Service API
- user model changes: no
- storage format changes: no
- interface changes: yes
- Add ICoordinationService to CC and NC
application context.
Details:
- Add API to support coordination service.
- An initial no-op implementation of coordination
service.
Change-Id: I8670e3498a141029d21826a2908033510c749838
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2244
Sonar-Qube: Jenkins <[email protected]>
Tested-by: Jenkins <[email protected]>
Contrib: Jenkins <[email protected]>
Integration-Tests: Jenkins <[email protected]>
Reviewed-by: Michael Blow <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/d9072335
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/d9072335
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/d9072335
Branch: refs/heads/master
Commit: d90723359740d71df4a4d671d311716dac5495cb
Parents: 6868d7d
Author: Murtadha Hubail <[email protected]>
Authored: Thu Dec 21 02:45:16 2017 +0300
Committer: Murtadha Hubail <[email protected]>
Committed: Thu Dec 21 12:16:21 2017 -0800
----------------------------------------------------------------------
.../asterix/app/nc/NCAppRuntimeContext.java | 7 +++
.../asterix/common/api/IApplicationContext.java | 5 +++
.../common/api/ICoordinationService.java | 45 ++++++++++++++++++++
.../runtime/utils/CcApplicationContext.java | 7 ++-
.../runtime/utils/NoOpCoordinationService.java | 41 ++++++++++++++++++
5 files changed, 104 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/d9072335/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/NCAppRuntimeContext.java
----------------------------------------------------------------------
diff --git
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/NCAppRuntimeContext.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/NCAppRuntimeContext.java
index a0142d5..425cbe4 100644
---
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/NCAppRuntimeContext.java
+++
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/NCAppRuntimeContext.java
@@ -31,6 +31,7 @@ import java.util.stream.Collectors;
import org.apache.asterix.active.ActiveManager;
import org.apache.asterix.api.common.AppRuntimeContextProviderForRecovery;
+import org.apache.asterix.common.api.ICoordinationService;
import org.apache.asterix.common.api.IDatasetLifecycleManager;
import org.apache.asterix.common.api.IDatasetMemoryManager;
import org.apache.asterix.common.api.INcApplicationContext;
@@ -76,6 +77,7 @@ import
org.apache.asterix.replication.management.ReplicationManager;
import org.apache.asterix.replication.recovery.RemoteRecoveryManager;
import org.apache.asterix.replication.storage.ReplicaResourcesManager;
import org.apache.asterix.runtime.transaction.GlobalResourceIdFactoryProvider;
+import org.apache.asterix.runtime.utils.NoOpCoordinationService;
import
org.apache.asterix.transaction.management.resource.PersistentLocalResourceRepository;
import
org.apache.asterix.transaction.management.resource.PersistentLocalResourceRepositoryFactory;
import org.apache.hyracks.api.application.INCServiceContext;
@@ -538,4 +540,9 @@ public class NCAppRuntimeContext implements
INcApplicationContext {
public IIndexCheckpointManagerProvider getIndexCheckpointManagerProvider()
{
return indexCheckpointManagerProvider;
}
+
+ @Override
+ public ICoordinationService getCoordinationService() {
+ return NoOpCoordinationService.INSTANCE;
+ }
}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/d9072335/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/IApplicationContext.java
----------------------------------------------------------------------
diff --git
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/IApplicationContext.java
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/IApplicationContext.java
index 4e30d54..6b5b472 100644
---
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/IApplicationContext.java
+++
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/IApplicationContext.java
@@ -71,4 +71,9 @@ public interface IApplicationContext {
* if connection couldn't be established to cluster controller
*/
IHyracksClientConnection getHcc() throws HyracksDataException;
+
+ /**
+ * @return the cluster coordination service.
+ */
+ ICoordinationService getCoordinationService();
}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/d9072335/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/ICoordinationService.java
----------------------------------------------------------------------
diff --git
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/ICoordinationService.java
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/ICoordinationService.java
new file mode 100644
index 0000000..6f929b1
--- /dev/null
+++
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/ICoordinationService.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.asterix.common.api;
+
+import java.util.Optional;
+
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public interface ICoordinationService {
+
+ /**
+ * Adds or updates the property with the name {@code key}
+ * with {@code value}
+ *
+ * @param key
+ * @param value
+ * @throws HyracksDataException
+ */
+ void put(String key, byte[] value) throws HyracksDataException;
+
+ /**
+ * Gets the value of the property with name {@code key} if exists.
+ *
+ * @param key
+ * @return optional with the value or {@link Optional#empty()}
+ * @throws HyracksDataException
+ */
+ Optional<byte[]> get(String key) throws HyracksDataException;
+}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/d9072335/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/CcApplicationContext.java
----------------------------------------------------------------------
diff --git
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/CcApplicationContext.java
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/CcApplicationContext.java
index c3ef5b3..f991cd4 100644
---
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/CcApplicationContext.java
+++
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/CcApplicationContext.java
@@ -21,6 +21,7 @@ package org.apache.asterix.runtime.utils;
import java.io.IOException;
import java.util.function.Supplier;
+import org.apache.asterix.common.api.ICoordinationService;
import org.apache.asterix.common.api.IMetadataLockManager;
import org.apache.asterix.common.api.INodeJobTracker;
import org.apache.asterix.common.cluster.IClusterStateManager;
@@ -106,7 +107,6 @@ public class CcApplicationContext implements
ICcApplicationContext {
extensionProperties = new ExtensionProperties(propertiesAccessor);
replicationProperties = new ReplicationProperties(propertiesAccessor);
this.ftStrategy = ftStrategy;
- this.hcc = hcc;
this.buildProperties = new BuildProperties(propertiesAccessor);
this.messagingProperties = new MessagingProperties(propertiesAccessor);
this.nodeProperties = new NodeProperties(propertiesAccessor);
@@ -260,4 +260,9 @@ public class CcApplicationContext implements
ICcApplicationContext {
public INodeJobTracker getNodeJobTracker() {
return nodeJobTracker;
}
+
+ @Override
+ public ICoordinationService getCoordinationService() {
+ return NoOpCoordinationService.INSTANCE;
+ }
}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/d9072335/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/NoOpCoordinationService.java
----------------------------------------------------------------------
diff --git
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/NoOpCoordinationService.java
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/NoOpCoordinationService.java
new file mode 100644
index 0000000..ed29f4b
--- /dev/null
+++
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/NoOpCoordinationService.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.asterix.runtime.utils;
+
+import java.util.Optional;
+
+import org.apache.asterix.common.api.ICoordinationService;
+
+public class NoOpCoordinationService implements ICoordinationService {
+
+ public static final NoOpCoordinationService INSTANCE = new
NoOpCoordinationService();
+
+ private NoOpCoordinationService() {
+ }
+
+ @Override
+ public void put(String key, byte[] value) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Optional<byte[]> get(String key) {
+ throw new UnsupportedOperationException();
+ }
+}