Implement the core DatasetDirectoryService class.
In the current implementation there will be one dataset directory
service per job, but this is going to change soon to a single global
dataset directory service for the cluster controller instance.
git-svn-id: https://hyracks.googlecode.com/svn/branches/fullstack_hyracks_result_distribution@2470 123451ca-8445-de46-9d55-352943316053
diff --git a/hyracks/hyracks-control/hyracks-control-cc/src/main/java/edu/uci/ics/hyracks/control/cc/dataset/DatasetDirectoryService.java b/hyracks/hyracks-control/hyracks-control-cc/src/main/java/edu/uci/ics/hyracks/control/cc/dataset/DatasetDirectoryService.java
new file mode 100644
index 0000000..402e430
--- /dev/null
+++ b/hyracks/hyracks-control/hyracks-control-cc/src/main/java/edu/uci/ics/hyracks/control/cc/dataset/DatasetDirectoryService.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2009-2010 by The Regents of the University of California
+ * 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 from
+ *
+ * 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 edu.uci.ics.hyracks.control.cc.dataset;
+
+import java.util.Arrays;
+
+import edu.uci.ics.hyracks.api.comm.NetworkAddress;
+import edu.uci.ics.hyracks.api.dataset.IDatasetDirectoryService;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+
+public class DatasetDirectoryService implements IDatasetDirectoryService {
+ private NetworkAddress[] partitionLocations;
+
+ public DatasetDirectoryService() {
+ partitionLocations = null;
+ }
+
+ @Override
+ public synchronized void registerResultPartitionLocation(int partition, int nPartitions,
+ NetworkAddress networkAddress) {
+ if (partitionLocations == null) {
+ partitionLocations = new NetworkAddress[nPartitions];
+ }
+
+ partitionLocations[partition] = networkAddress;
+ notifyAll();
+ }
+
+ @Override
+ public synchronized NetworkAddress[] getResultPartitionLocations(NetworkAddress[] knownLocations)
+ throws HyracksDataException {
+ while (Arrays.equals(partitionLocations, knownLocations)) {
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ throw new HyracksDataException(e);
+ }
+ }
+ return partitionLocations;
+ }
+}
\ No newline at end of file