asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Murtadha Hubail (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: [ASTERIXDB-2207][CLUS] Introduce Coordination Service API
Date Wed, 20 Dec 2017 23:46:27 GMT
Murtadha Hubail has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/2244

Change subject: [ASTERIXDB-2207][CLUS] Introduce Coordination Service API
......................................................................

[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
---
M asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/NCAppRuntimeContext.java
M asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/IApplicationContext.java
A asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/ICoordinationService.java
M asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/CcApplicationContext.java
A asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/NoOpCoordinationService.java
5 files changed, 104 insertions(+), 1 deletion(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/44/2244/1

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 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.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 IIndexCheckpointManagerProvider getIndexCheckpointManagerProvider() {
         return indexCheckpointManagerProvider;
     }
+
+    @Override
+    public ICoordinationService getCoordinationService() {
+        return NoOpCoordinationService.INSTANCE;
+    }
 }
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 @@
      *             if connection couldn't be established to cluster controller
      */
     IHyracksClientConnection getHcc() throws HyracksDataException;
+
+    /**
+     * @return the cluster coordination service.
+     */
+    ICoordinationService getCoordinationService();
 }
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;
+}
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 @@
 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 @@
         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 INodeJobTracker getNodeJobTracker() {
         return nodeJobTracker;
     }
+
+    @Override
+    public ICoordinationService getCoordinationService() {
+        return NoOpCoordinationService.INSTANCE;
+    }
 }
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();
+    }
+}

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/2244
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8670e3498a141029d21826a2908033510c749838
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Murtadha Hubail <mhubail@apache.org>

Mime
View raw message