You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@reef.apache.org by we...@apache.org on 2014/10/23 02:04:06 UTC
[35/51] [abbrv] [partial] Initial merge of Wake,
Tang and REEF into one repository and project
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/runtime/common/parameters/JVMHeapSlack.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/runtime/common/parameters/JVMHeapSlack.java b/reef-common/src/main/java/com/microsoft/reef/runtime/common/parameters/JVMHeapSlack.java
deleted file mode 100644
index 167436f..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/runtime/common/parameters/JVMHeapSlack.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.runtime.common.parameters;
-
-import com.microsoft.tang.annotations.Name;
-import com.microsoft.tang.annotations.NamedParameter;
-
-/**
- * The fraction of the container memory NOT to use for the Java Heap.
- */
-@NamedParameter(doc = "The fraction of the container memory NOT to use for the Java Heap.", default_value = "0.0")
-public final class JVMHeapSlack implements Name<Double> {
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/runtime/common/utils/BroadCastEventHandler.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/runtime/common/utils/BroadCastEventHandler.java b/reef-common/src/main/java/com/microsoft/reef/runtime/common/utils/BroadCastEventHandler.java
deleted file mode 100644
index 8203296..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/runtime/common/utils/BroadCastEventHandler.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.runtime.common.utils;
-
-import com.microsoft.wake.EventHandler;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-public class BroadCastEventHandler<E> implements EventHandler<E> {
- private final List<EventHandler<E>> handlers;
-
- public BroadCastEventHandler(final Collection<EventHandler<E>> handlers) {
- this.handlers = new ArrayList<>(handlers);
- }
-
- @Override
- public void onNext(final E event) {
- for (final EventHandler<E> handler : handlers)
- handler.onNext(event);
- }
-
- public void addEventHandler(final EventHandler<E> eventHandler) {
- this.handlers.add(eventHandler);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/runtime/common/utils/DefaultExceptionCodec.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/runtime/common/utils/DefaultExceptionCodec.java b/reef-common/src/main/java/com/microsoft/reef/runtime/common/utils/DefaultExceptionCodec.java
deleted file mode 100644
index e092b2b..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/runtime/common/utils/DefaultExceptionCodec.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.runtime.common.utils;
-
-import com.microsoft.reef.annotations.audience.Private;
-import com.microsoft.reef.util.Optional;
-import org.apache.commons.lang.SerializationException;
-import org.apache.commons.lang.SerializationUtils;
-
-import javax.inject.Inject;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Default implementation of ExceptionCodec that uses Java serialization as its implementation.
- */
-@Private
-final class DefaultExceptionCodec implements ExceptionCodec {
- private static final Logger LOG = Logger.getLogger(DefaultExceptionCodec.class.getName());
-
- @Inject
- DefaultExceptionCodec() {
- }
-
- @Override
- public Optional<Throwable> fromBytes(final byte[] bytes) {
- try {
- return Optional.<Throwable>of((Throwable) SerializationUtils.deserialize(bytes));
- } catch (SerializationException | IllegalArgumentException e) {
- LOG.log(Level.FINE, "Unable to deserialize a Throwable.", e);
- return Optional.empty();
- }
- }
-
- @Override
- public Optional<Throwable> fromBytes(final Optional<byte[]> bytes) {
- if (bytes.isPresent()) {
- return this.fromBytes(bytes.get());
- } else {
- return Optional.empty();
- }
- }
-
- @Override
- public byte[] toBytes(final Throwable throwable) {
- return SerializationUtils.serialize(throwable);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/runtime/common/utils/DispatchingEStage.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/runtime/common/utils/DispatchingEStage.java b/reef-common/src/main/java/com/microsoft/reef/runtime/common/utils/DispatchingEStage.java
deleted file mode 100644
index 2e0e237..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/runtime/common/utils/DispatchingEStage.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.runtime.common.utils;
-
-import com.microsoft.reef.annotations.audience.DriverSide;
-import com.microsoft.reef.annotations.audience.Private;
-import com.microsoft.reef.util.ExceptionHandlingEventHandler;
-import com.microsoft.tang.util.MonotonicHashMap;
-import com.microsoft.wake.EventHandler;
-import com.microsoft.wake.impl.ThreadPoolStage;
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Delayed event router that dispatches messages to the proper event handler by type.
- * This class is used in EvaluatorManager to isolate user threads from REEF.
- */
-@Private
-@DriverSide
-public final class DispatchingEStage implements AutoCloseable {
-
- /**
- * Delayed EventHandler.onNext() call.
- * Contains a message object and EventHandler to process it.
- */
- private static final class DelayedOnNext {
-
- public final EventHandler<Object> handler;
- public final Object message;
-
- @SuppressWarnings("unchecked")
- public <T, U extends T> DelayedOnNext(final EventHandler<T> handler, final U message) {
- this.handler = (EventHandler<Object>) handler;
- this.message = message;
- }
- }
-
- /**
- * A map of event handlers, populated in the register() method.
- */
- private final Map<Class<?>, EventHandler<?>> handlers =
- Collections.synchronizedMap(new MonotonicHashMap<Class<?>, EventHandler<?>>());
-
- /**
- * Exception handler, one for all event handlers.
- */
- private final EventHandler<Throwable> errorHandler;
-
- /**
- * Thread pool to process delayed event handler invocations.
- */
- private final ThreadPoolStage<DelayedOnNext> stage;
-
- /**
- * @param errorHandler used for exceptions thrown from the event handlers registered.
- * @param numThreads number of threads to allocate to dispatch events.
- * @param stageName the name to use for the underlying stage. It will be carried over to name the Thread(s) spawned.
- */
- public DispatchingEStage(final EventHandler<Throwable> errorHandler,
- final int numThreads,
- final String stageName) {
- this.errorHandler = errorHandler;
- this.stage = new ThreadPoolStage<>(stageName,
- new EventHandler<DelayedOnNext>() {
- @Override
- public void onNext(final DelayedOnNext promise) {
- promise.handler.onNext(promise.message);
- }
- }, numThreads
- );
-
- }
-
- /**
- * Constructs a DispatchingEStage that uses the Thread pool and ErrorHandler of another one.
- *
- * @param other
- */
- public DispatchingEStage(final DispatchingEStage other) {
- this.errorHandler = other.errorHandler;
- this.stage = other.stage;
- }
-
- /**
- * Register a new event handler.
- *
- * @param type Message type to process with this handler.
- * @param handlers A set of handlers that process that type of message.
- * @param <T> Message type.
- * @param <U> Type of message that event handler supports. Must be a subclass of T.
- */
- public <T, U extends T> void register(final Class<T> type, final Set<EventHandler<U>> handlers) {
- this.handlers.put(type, new ExceptionHandlingEventHandler<>(
- new BroadCastEventHandler<>(handlers), this.errorHandler));
- }
-
- /**
- * Dispatch a new message by type.
- *
- * @param type Type of event handler - must match the register() call.
- * @param message A message to process. Must be a subclass of T.
- * @param <T> Message type that event handler supports.
- * @param <U> input message type. Must be a subclass of T.
- */
- @SuppressWarnings("unchecked")
- public <T, U extends T> void onNext(final Class<T> type, final U message) {
- final EventHandler<T> handler = (EventHandler<T>) this.handlers.get(type);
- this.stage.onNext(new DelayedOnNext(handler, message));
- }
-
- /**
- * Return true if there are no messages queued or in processing, false otherwise.
- */
- public boolean isEmpty() {
- return this.stage.getQueueLength() == 0;
- }
-
- /**
- * Close the internal thread pool.
- *
- * @throws Exception forwarded from EStage.close() call.
- */
- @Override
- public void close() throws Exception {
- this.stage.close();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/runtime/common/utils/ExceptionCodec.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/runtime/common/utils/ExceptionCodec.java b/reef-common/src/main/java/com/microsoft/reef/runtime/common/utils/ExceptionCodec.java
deleted file mode 100644
index 56560f9..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/runtime/common/utils/ExceptionCodec.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.runtime.common.utils;
-
-import com.microsoft.reef.util.Optional;
-import com.microsoft.tang.annotations.DefaultImplementation;
-
-/**
- * (De-)serializes exceptions.
- */
-@DefaultImplementation(DefaultExceptionCodec.class)
-public interface ExceptionCodec {
-
- /**
- * Deserializes a Throwable that has been serialized using toBytes().
- *
- * @param bytes
- * @return the Throable or Optional.empty() if the deserialization fails.
- */
- public Optional<Throwable> fromBytes(final byte[] bytes);
-
- /**
- * @param bytes
- * @return fromBytes(bytes.get()) or Optional.empty()
- */
- public Optional<Throwable> fromBytes(final Optional<byte[]> bytes);
-
- /**
- * @param throwable
- * @return the serialized form of the given Throwable.
- */
- public byte[] toBytes(final Throwable throwable);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/runtime/common/utils/RemoteManager.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/runtime/common/utils/RemoteManager.java b/reef-common/src/main/java/com/microsoft/reef/runtime/common/utils/RemoteManager.java
deleted file mode 100644
index 98ac249..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/runtime/common/utils/RemoteManager.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.runtime.common.utils;
-
-import com.microsoft.wake.EventHandler;
-import com.microsoft.wake.remote.RemoteIdentifierFactory;
-import com.microsoft.wake.remote.RemoteMessage;
-
-import javax.inject.Inject;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-public class RemoteManager {
-
- private static final Logger LOG = Logger.getLogger(RemoteManager.class.getName());
-
- private final com.microsoft.wake.remote.RemoteManager raw;
- private final RemoteIdentifierFactory factory;
-
- @Inject
- public RemoteManager(final com.microsoft.wake.remote.RemoteManager raw,
- final RemoteIdentifierFactory factory) {
- this.raw = raw;
- this.factory = factory;
- LOG.log(Level.FINE, "Instantiated 'RemoteManager' with remoteId: {0}", this.getMyIdentifier());
- }
-
- public final com.microsoft.wake.remote.RemoteManager raw() {
- return this.raw;
- }
-
- public void close() throws Exception {
- this.raw.close();
- }
-
- public <T> EventHandler<T> getHandler(
- final String destinationIdentifier, final Class<? extends T> messageType) {
- return this.raw.getHandler(factory.getNewInstance(destinationIdentifier), messageType);
- }
-
- public <T, U extends T> AutoCloseable registerHandler(
- final String sourceIdentifier, final Class<U> messageType,
- final EventHandler<T> theHandler) {
- return this.raw.registerHandler(factory.getNewInstance(sourceIdentifier), messageType, theHandler);
- }
-
- public <T, U extends T> AutoCloseable registerHandler(
- final Class<U> messageType, final EventHandler<RemoteMessage<T>> theHandler) {
- return this.raw.registerHandler(messageType, theHandler);
- }
-
- public AutoCloseable registerErrorHandler(final EventHandler<Exception> theHandler) {
- return this.raw.registerErrorHandler(theHandler);
- }
-
- public String getMyIdentifier() {
- return this.raw.getMyIdentifier().toString();
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/task/Task.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/task/Task.java b/reef-common/src/main/java/com/microsoft/reef/task/Task.java
deleted file mode 100644
index a801ff5..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/task/Task.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.task;
-
-import com.microsoft.reef.annotations.audience.Public;
-import com.microsoft.reef.annotations.audience.TaskSide;
-
-import java.util.concurrent.Callable;
-
-/**
- * The interface for Tasks.
- * <p/>
- * This interface is to be implemented for Tasks.
- * <p/>
- * The main entry point for a Task is the call() method inherited from
- * {@link Callable}. The REEF Evaluator will call this method in order to run
- * the Task. The byte[] returned by it will be pushed to the Job Driver.
- */
-@TaskSide
-@Public
-public interface Task {
-
- /**
- * Called by the resourcemanager harness to execute the task.
- *
- * @param memento the memento objected passed down by the driver.
- * @return the user defined return value
- * @throws Exception whenever the Task encounters an unsolved issue.
- * This Exception will be thrown at the Driver's event handler.
- */
- public byte[] call(final byte[] memento) throws Exception;
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/task/TaskMessage.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/task/TaskMessage.java b/reef-common/src/main/java/com/microsoft/reef/task/TaskMessage.java
deleted file mode 100644
index 4a036df..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/task/TaskMessage.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.task;
-
-
-import com.microsoft.reef.annotations.Provided;
-import com.microsoft.reef.annotations.audience.EvaluatorSide;
-import com.microsoft.reef.annotations.audience.Public;
-import com.microsoft.reef.io.Message;
-
-/**
- * A message sent from a Task to a Driver.
- */
-@EvaluatorSide
-@Public
-@Provided
-public final class TaskMessage implements Message {
-
- private final String messageSourceID;
- private final byte[] theBytes;
-
- private TaskMessage(final String messageSourceID, final byte[] theBytes) {
- this.messageSourceID = messageSourceID;
- this.theBytes = theBytes;
- }
-
- /**
- * @return the message source identifier.
- */
- public String getMessageSourceID() {
- return this.messageSourceID;
- }
-
- /**
- * @return the message
- */
- @Override
- public byte[] get() {
- return this.theBytes;
- }
-
- /**
- * @param messageSourceID The message's sourceID. This will be accessible in the Driver for routing.
- * @param theBytes The actual content of the message, serialized into a byte[]
- * @return a new TaskMessage with the given content.
- */
- public static TaskMessage from(final String messageSourceID, final byte[] theBytes) {
- assert (theBytes != null && messageSourceID != null);
- return new TaskMessage(messageSourceID, theBytes);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/task/TaskMessageSource.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/task/TaskMessageSource.java b/reef-common/src/main/java/com/microsoft/reef/task/TaskMessageSource.java
deleted file mode 100644
index 7da3ae9..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/task/TaskMessageSource.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.task;
-
-import com.microsoft.reef.annotations.audience.EvaluatorSide;
-import com.microsoft.reef.annotations.audience.Public;
-import com.microsoft.reef.util.Optional;
-
-/**
- * Message source for control flow messages from a task to the Driver.
- * <p/>
- * The getMessage() method in an Implementation of this interface will be called by the Evaluator resourcemanager whenever it is
- * about to communicate with the Driver anyway. Hence, this can be used for occasional status updates etc.
- */
-@Public
-@EvaluatorSide
-public interface TaskMessageSource {
-
- /**
- * @return a message to be sent back to the Driver, or Optional.empty() if no message shall be sent at this time.
- */
- public Optional<TaskMessage> getMessage();
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/task/events/CloseEvent.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/task/events/CloseEvent.java b/reef-common/src/main/java/com/microsoft/reef/task/events/CloseEvent.java
deleted file mode 100644
index c238e48..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/task/events/CloseEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.task.events;
-
-import com.microsoft.reef.annotations.Provided;
-import com.microsoft.reef.annotations.audience.TaskSide;
-import com.microsoft.reef.annotations.audience.Public;
-import com.microsoft.reef.util.Optional;
-
-/**
- * Indicates that the driver called .close() on this Task.
- */
-@TaskSide
-@Provided
-@Public
-public interface CloseEvent {
-
- /**
- * @return the message sent with the close call, if any.
- */
- public Optional<byte[]> get();
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/task/events/DriverMessage.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/task/events/DriverMessage.java b/reef-common/src/main/java/com/microsoft/reef/task/events/DriverMessage.java
deleted file mode 100644
index 4275a42..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/task/events/DriverMessage.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.task.events;
-
-import com.microsoft.reef.annotations.Provided;
-import com.microsoft.reef.annotations.audience.TaskSide;
-import com.microsoft.reef.annotations.audience.Public;
-import com.microsoft.reef.util.Optional;
-
-/**
- * Represents a message sent by the driver.
- */
-@TaskSide
-@Public
-@Provided
-public interface DriverMessage {
-
- /**
- * @return the message sent by the driver.
- */
- public Optional<byte[]> get();
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/task/events/SuspendEvent.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/task/events/SuspendEvent.java b/reef-common/src/main/java/com/microsoft/reef/task/events/SuspendEvent.java
deleted file mode 100644
index 21bb18a..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/task/events/SuspendEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.task.events;
-
-import com.microsoft.reef.annotations.Provided;
-import com.microsoft.reef.annotations.audience.TaskSide;
-import com.microsoft.reef.annotations.audience.Public;
-import com.microsoft.reef.util.Optional;
-
-/**
- * Event fired when the driver called suspend() on this task.
- */
-@TaskSide
-@Provided
-@Public
-public interface SuspendEvent {
-
- /**
- * @return the message sent with the suspend call, if any.
- */
- public Optional<byte[]> get();
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/task/events/TaskStart.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/task/events/TaskStart.java b/reef-common/src/main/java/com/microsoft/reef/task/events/TaskStart.java
deleted file mode 100644
index 8ed7222..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/task/events/TaskStart.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.task.events;
-
-import com.microsoft.reef.annotations.audience.EvaluatorSide;
-import com.microsoft.reef.annotations.audience.Public;
-import com.microsoft.reef.io.naming.Identifiable;
-
-/**
- * Represents a TaskStart. Fired right before Task.call() is invoked.
- */
-@EvaluatorSide
-@Public
-public interface TaskStart extends Identifiable {
-
- /**
- * @return task identifier.
- */
- @Override
- String getId();
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/task/events/TaskStop.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/task/events/TaskStop.java b/reef-common/src/main/java/com/microsoft/reef/task/events/TaskStop.java
deleted file mode 100644
index 1152755..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/task/events/TaskStop.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.task.events;
-
-import com.microsoft.reef.annotations.audience.EvaluatorSide;
-import com.microsoft.reef.annotations.audience.Public;
-import com.microsoft.reef.io.naming.Identifiable;
-
-/**
- * Represents a Task stop. Fired right after Task.call() returned.
- */
-@EvaluatorSide
-@Public
-public interface TaskStop extends Identifiable {
-
- /**
- * @return the task identifier
- */
- public String getId();
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/util/Builder.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/util/Builder.java b/reef-common/src/main/java/com/microsoft/reef/util/Builder.java
deleted file mode 100644
index 8486596..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/util/Builder.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.util;
-
-/**
- * A basic Builder pattern interface.
- *
- * @param <T> The type of object to be built.
- */
-public interface Builder<T> {
-
- /**
- * Builds a fresh instance of the object. This can be invoked several times,
- * each of which return a new instance.
- *
- * @return a fresh instance of the object.
- */
- public T build();
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/util/CommandUtils.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/util/CommandUtils.java b/reef-common/src/main/java/com/microsoft/reef/util/CommandUtils.java
deleted file mode 100644
index ab2e56d..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/util/CommandUtils.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.util;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * run given command and return the result as string
- */
-final public class CommandUtils {
- /** Standard java logger. */
- private static final Logger LOG = Logger.getLogger(CommandUtils.class.getName());
-
- public final static String runCommand(final String command) {
- final StringBuilder sb = new StringBuilder();
- try {
- final String cmd = OSUtils.isWindows() ? "cmd.exe /c " + command : command;
- final Process proc = Runtime.getRuntime().exec(cmd);
-
- try (final BufferedReader input =
- new BufferedReader(new InputStreamReader(proc.getInputStream()))) {
- String line;
- while ((line = input.readLine()) != null) {
- sb.append(line).append('\n');
- }
- }
- } catch (final IOException ex) {
- LOG.log(Level.SEVERE, "Error in call: " + command, ex);
- sb.append(ex);
- }
- return sb.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/util/EnvironmentUtils.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/util/EnvironmentUtils.java b/reef-common/src/main/java/com/microsoft/reef/util/EnvironmentUtils.java
deleted file mode 100644
index 2a39f8a..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/util/EnvironmentUtils.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.util;
-
-import com.microsoft.tang.formats.ConfigurationModule;
-import com.microsoft.tang.formats.OptionalParameter;
-import com.microsoft.tang.formats.Param;
-
-import java.io.File;
-import java.nio.file.InvalidPathException;
-import java.nio.file.Path;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-public final class EnvironmentUtils {
-
- private static final Logger LOG = Logger.getLogger(EnvironmentUtils.class.getName());
-
- /**
- * Get a set of all classpath entries EXCEPT of those under
- * $JAVA_HOME, $YARN_HOME, and $HADOOP_HOME.
- *
- * @return A set of classpath entries as strings.
- */
- public static Set<String> getAllClasspathJars() {
- return getAllClasspathJars(
- "JAVA_HOME",
- "YARN_HOME",
- "HADOOP_HOME",
- "HADOOP_YARN_HOME",
- "HADOOP_HDFS_HOME",
- "HADOOP_COMMON_HOME",
- "HADOOP_MAPRED_HOME",
- "YARN_CONF_DIR",
- "HADOOP_CONF_DIR");
- }
-
- /**
- * Get a set of all classpath entries EXCEPT of those under excludeEnv directories.
- * Every excludeEnv entry is an environment variable name.
- *
- * @return A set of classpath entries as strings.
- */
- public static Set<String> getAllClasspathJars(final String... excludeEnv) {
-
- final Set<String> jars = new HashSet<>();
- final Set<Path> excludePaths = new HashSet<>();
-
- for (final String env : excludeEnv) {
- final String path = System.getenv(env);
- if (null != path) {
- final File file = new File(path);
- if (file.exists()) {
- excludePaths.add(file.toPath());
- }
- }
- }
-
- for (final String path : System.getProperty("java.class.path").split(File.pathSeparator)) {
- try {
- final File file = new File(path);
- if (file.exists()) {
- final Path absolutePath = file.toPath();
- boolean toBeAdded = true;
- for (final Path prefix : excludePaths) {
- if (absolutePath.startsWith(prefix)) {
- toBeAdded = false;
- }
- }
- if (toBeAdded) {
- jars.add(absolutePath.toString());
- }
- }
- } catch (final InvalidPathException ex) {
- LOG.log(Level.FINE, "Skip path: {0}: {1}", new Object[]{path, ex});
- }
- }
-
- return jars;
- }
-
- /**
- * @param config
- * @param param
- * @param values
- * @param <P>
- * @return
- * @deprecated in 0.2 this really should be in Tang.
- * See <a href="https://github.com/Microsoft-CISL/TANG/issues/164">Tang #164</a> for details.
- */
- @Deprecated
- public static <P extends Param> ConfigurationModule addAll(
- ConfigurationModule config, final P param, final Iterable<String> values) {
- for (final String val : values) {
- config = config.set(param, val);
- }
- return config;
- }
-
- /**
- * @param config
- * @param param
- * @return
- * @deprecated Using this method is inherently non-deterministic as it depends on environment variables on your local
- * machine.
- */
- @Deprecated
- public static ConfigurationModule addClasspath(
- final ConfigurationModule config, final OptionalParameter<String> param) {
- return addAll(config, param, getAllClasspathJars());
- }
-
- /**
- * Check whether assert() statements are evaluated.
- *
- * @return true, if assertions are enabled. False otherwise.
- */
- public static boolean areAssertionsEnabled() {
- try {
- assert false;
- // If we got here, the assert above can't have thrown an exception. hence, asserts must be off.
- return false;
- } catch (final AssertionError assertionError) {
- // The assert above threw an exception. Asserts must be enabled.
- return true;
- }
- }
-
- /**
- * @param clazz
- * @return the location (JAR or .class file) where the given class is located.
- */
- public static String getClassLocation(final Class<?> clazz) {
- return clazz.getProtectionDomain().getCodeSource().getLocation().getFile();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/util/ExceptionHandlingEventHandler.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/util/ExceptionHandlingEventHandler.java b/reef-common/src/main/java/com/microsoft/reef/util/ExceptionHandlingEventHandler.java
deleted file mode 100644
index 9a2c9e8..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/util/ExceptionHandlingEventHandler.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.util;
-
-import com.microsoft.reef.annotations.audience.Private;
-import com.microsoft.wake.EventHandler;
-
-/**
- * An ExceptionHandler that wraps another one, but catches all exceptions thrown by that one and forwards them
- * to an ExceptionHandler.
- *
- * @param <T> the event type handled
- */
-@Private
-public final class ExceptionHandlingEventHandler<T> implements EventHandler<T> {
-
- private final EventHandler<T> wrapped;
- private final EventHandler<Throwable> exceptionHandler;
-
- public ExceptionHandlingEventHandler(final EventHandler<T> wrapped,
- final EventHandler<Throwable> exceptionHandler) {
- this.wrapped = wrapped;
- this.exceptionHandler = exceptionHandler;
- }
-
- @Override
- public void onNext(final T t) {
- try {
- this.wrapped.onNext(t);
- } catch (final Throwable throwable) {
- this.exceptionHandler.onNext(throwable);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/util/Exceptions.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/util/Exceptions.java b/reef-common/src/main/java/com/microsoft/reef/util/Exceptions.java
deleted file mode 100644
index ec85bd8..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/util/Exceptions.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.util;
-
-/**
- * Utility class to deal with Exceptions
- */
-public final class Exceptions {
- private Exceptions() {
- }
-
- /**
- * Walks the .getCause() chain till it hits the leaf node.
- *
- * @param throwable
- * @return
- */
- public static Throwable getUltimateCause(final Throwable throwable) {
- if (throwable.getCause() == null) {
- return throwable;
- } else {
- return getUltimateCause(throwable.getCause());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/util/JARFileMaker.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/util/JARFileMaker.java b/reef-common/src/main/java/com/microsoft/reef/util/JARFileMaker.java
deleted file mode 100644
index cde8be7..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/util/JARFileMaker.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.util;
-
-import org.apache.commons.compress.utils.IOUtils;
-
-import java.io.*;
-import java.util.jar.JarEntry;
-import java.util.jar.JarOutputStream;
-import java.util.jar.Manifest;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Helper class to create JAR files.
- */
-public class JARFileMaker implements AutoCloseable {
-
- private static final Logger LOG = Logger.getLogger(JARFileMaker.class.getName());
-
- private final FileOutputStream fileOutputStream;
- private final JarOutputStream jarOutputStream;
- private String relativeStartCanonicalPath = null;
-
- public JARFileMaker(final File outputFile, final Manifest manifest) throws IOException {
- this.fileOutputStream = new FileOutputStream(outputFile);
- this.jarOutputStream = new JarOutputStream(this.fileOutputStream, manifest);
- }
-
- public JARFileMaker(final File outputFile) throws IOException {
- this.fileOutputStream = new FileOutputStream(outputFile);
- this.jarOutputStream = new JarOutputStream(this.fileOutputStream);
- }
-
- /**
- * Adds a file to the JAR. If inputFile is a folder, it will be added recursively.
- *
- * @param inputFile
- * @throws IOException
- */
- public JARFileMaker add(final File inputFile) throws IOException {
-
- final String fileNameInJAR = makeRelative(inputFile);
- if (inputFile.isDirectory()) {
- final JarEntry entry = new JarEntry(fileNameInJAR);
- entry.setTime(inputFile.lastModified());
- this.jarOutputStream.putNextEntry(entry);
- this.jarOutputStream.closeEntry();
- for (final File nestedFile : inputFile.listFiles()) {
- add(nestedFile);
- }
- return this;
- }
-
- final JarEntry entry = new JarEntry(fileNameInJAR);
- entry.setTime(inputFile.lastModified());
- this.jarOutputStream.putNextEntry(entry);
- try (final BufferedInputStream in = new BufferedInputStream(new FileInputStream(inputFile))) {
- IOUtils.copy(in, this.jarOutputStream);
- this.jarOutputStream.closeEntry();
- } catch (final FileNotFoundException ex) {
- LOG.log(Level.WARNING, "Skip the file: " + inputFile, ex);
- }
- return this;
- }
-
- public JARFileMaker addChildren(final File folder) throws IOException {
- this.relativeStartCanonicalPath = folder.getCanonicalPath();
- for (final File f : folder.listFiles()) {
- this.add(f);
- }
- this.relativeStartCanonicalPath = null;
- return this;
- }
-
- private String makeRelative(final File input) throws IOException {
- final String result;
- if (this.relativeStartCanonicalPath == null) {
- result = input.getCanonicalPath();
- } else {
- result = input.getCanonicalPath()
- .replace(this.relativeStartCanonicalPath, "") // Drop the absolute prefix
- .substring(1); // drop the '/' at the beginning
- }
- if (input.isDirectory()) {
- return result.replace("\\", "/") + "/";
- } else {
- return result.replace("\\", "/");
- }
-
- }
-
- @Override
- public void close() throws IOException {
- this.jarOutputStream.close();
- this.fileOutputStream.close();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/util/MemoryUtils.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/util/MemoryUtils.java b/reef-common/src/main/java/com/microsoft/reef/util/MemoryUtils.java
deleted file mode 100644
index 1d002bc..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/util/MemoryUtils.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2014 Microsoft.
- *
- * 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.
- */
-package com.microsoft.reef.util;
-
-import java.lang.management.ManagementFactory;
-import java.lang.management.MemoryPoolMXBean;
-import java.util.List;
-
-/**
- * Utility class to report current and peak memory
- * usage. Structured to be used while logging. Is
- * useful for debugging memory issues
- */
-public final class MemoryUtils {
-
- private static final int MBs = 1024 * 1024;
-
- private MemoryUtils () {
- }
-
- public static String memPoolNames() {
- final List<MemoryPoolMXBean> memoryPoolMXBeans = ManagementFactory.getMemoryPoolMXBeans();
- final StringBuilder output = new StringBuilder();
- for(final MemoryPoolMXBean bean : memoryPoolMXBeans) {
- output.append(bean.getName());
- output.append(",");
- }
- output.deleteCharAt(output.length()-1);
- return output.toString();
- }
-
- public static long currentEdenMemoryUsageMB() {
- return currentMemoryUsage("eden");
- }
-
- public static long currentOldMemoryUsageMB() {
- return currentMemoryUsage("old");
- }
-
- public static long currentPermMemoryUsageMB() {
- return currentMemoryUsage("perm");
- }
-
- private static long currentMemoryUsage(final String name) {
- final List<MemoryPoolMXBean> memoryPoolMXBeans = ManagementFactory.getMemoryPoolMXBeans();
- for (final MemoryPoolMXBean bean : memoryPoolMXBeans) {
- if (bean.getName().toLowerCase().indexOf(name) != -1) {
- return bean.getUsage().getUsed() / MBs;
- }
- }
- return 0;
- }
-
- public static long peakEdenMemoryUsageMB() {
- return peakMemoryUsage("eden");
- }
-
- public static long peakOldMemoryUsageMB() {
- return peakMemoryUsage("old");
- }
-
- public static long peakPermMemoryUsageMB() {
- return peakMemoryUsage("perm");
- }
-
- private static long peakMemoryUsage(final String name) {
- final List<MemoryPoolMXBean> memoryPoolMXBeans = ManagementFactory.getMemoryPoolMXBeans();
- for (final MemoryPoolMXBean bean : memoryPoolMXBeans) {
- if (bean.getName().toLowerCase().indexOf(name) != -1) {
- return bean.getPeakUsage().getUsed() / MBs;
- }
- }
- return 0;
- }
-
- public static void resetPeakUsage() {
- final List<MemoryPoolMXBean> memoryPoolMXBeans = ManagementFactory.getMemoryPoolMXBeans();
- for (final MemoryPoolMXBean memoryPoolMXBean : memoryPoolMXBeans) {
- memoryPoolMXBean.resetPeakUsage();
- }
- }
-
- public static void main(final String[] args) {
- System.out.println(memPoolNames());
- {
- final byte[] b = new byte[1<<24];
- System.out.println(currentEdenMemoryUsageMB()
- + "," + currentOldMemoryUsageMB()
- + "," + currentPermMemoryUsageMB());
- }
-
- System.gc();
- System.out.println(currentEdenMemoryUsageMB()
- + "," + currentOldMemoryUsageMB()
- + "," + currentPermMemoryUsageMB());
- System.out.println(peakEdenMemoryUsageMB()
- + "," + peakOldMemoryUsageMB()
- + "," + peakPermMemoryUsageMB());
- resetPeakUsage();
- System.out.println(peakEdenMemoryUsageMB()
- + "," + peakOldMemoryUsageMB()
- + "," + peakPermMemoryUsageMB());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/util/OSUtils.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/util/OSUtils.java b/reef-common/src/main/java/com/microsoft/reef/util/OSUtils.java
deleted file mode 100644
index 630b7e3..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/util/OSUtils.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.util;
-
-import java.io.IOException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-public final class OSUtils {
- private static final Logger LOG = Logger.getLogger(OSUtils.class.getName());
-
- private OSUtils() {
- }
-
- /**
- * Determines whether the current JVM is running on the Windows OS.
- *
- * @return true, if the JVM is running on Windows. false, otherwise
- */
- public static boolean isWindows() {
- return System.getProperty("os.name").toLowerCase().contains("windows");
- }
-
- /**
- * Determines whether the current JVM is running on the Linux OS.
- *
- * @return true, if the JVM is running on Linux. false, otherwise
- */
- public static boolean isLinux() {
- return System.getProperty("os.name").toLowerCase().contains("linux");
- }
-
- /**
- * @return the process ID of the JVM, if running on Linux. This returns -1 for other OSs.
- */
- public static long getPID() {
- if (isLinux()) {
- try {
- final Process process = new ProcessBuilder()
- .command("bash", "-c", "echo $PPID")
- .start();
- final byte[] returnBytes = new byte[128];
- process.getInputStream().read(returnBytes);
- final Long result = Long.valueOf(new String(returnBytes).trim());
- process.destroy();
- return result;
- } catch (final IOException e) {
- LOG.log(Level.SEVERE, "Unable to determine PID", e);
- return -1;
- }
-
- } else {
- return -1;
- }
- }
-
- /**
- * Applies `kill -9` to the process.
- *
- * @param pid
- * @throws IOException
- */
- public static void kill(final long pid) throws IOException, InterruptedException {
- if (isLinux()) {
- final Process process = new ProcessBuilder()
- .command("bash", "-c", "kill", "-9", String.valueOf(pid))
- .start();
- final int returnCode = process.waitFor();
- LOG.fine("Kill returned: " + returnCode);
- } else {
- throw new UnsupportedOperationException("Unable to execute kill on non-linux OS");
- }
- }
-
- /**
- * Formats the given variable for expansion by Windows (<code>%VARIABE%</code>) or Linux (<code>$VARIABLE</code>)
- *
- * @param variableName
- * @return
- */
- public static String formatVariable(final String variableName) {
- if (isWindows()) {
- return "%" + variableName + "%";
- } else {
- return "$" + variableName;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/util/ObjectInstantiationLogger.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/util/ObjectInstantiationLogger.java b/reef-common/src/main/java/com/microsoft/reef/util/ObjectInstantiationLogger.java
deleted file mode 100644
index c4fb84d..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/util/ObjectInstantiationLogger.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.util;
-
-import javax.inject.Inject;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * A utility class used as a default at times.
- */
-public class ObjectInstantiationLogger {
- @Inject
- public ObjectInstantiationLogger() {
- Logger.getLogger(this.getClass().getName()).log(Level.FINER, "Instantiated");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/util/Optional.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/util/Optional.java b/reef-common/src/main/java/com/microsoft/reef/util/Optional.java
deleted file mode 100644
index ebc2c7b..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/util/Optional.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.util;
-
-import net.jcip.annotations.Immutable;
-import net.jcip.annotations.ThreadSafe;
-
-import java.io.Serializable;
-
-/**
- * Represents an optional value. Loosely based on
- * <a href="http://download.java.net/jdk8/docs/api/java/util/Optional.html"></a>The Java 8 version</a>, but filtered for
- * Java 7 compatibility.
- */
-@Immutable
-@ThreadSafe
-public final class Optional<T> implements Serializable {
-
- private static final long serialVersionUID = 42L;
-
- private final T value;
- private final String valueStr;
- private final int valueHash;
-
- private Optional(final T value) {
- this.value = value;
- this.valueStr = "Optional:{" + value + '}';
- this.valueHash = value.hashCode();
- }
-
- private Optional() {
- this.value = null;
- this.valueStr = "OptionalvNothing";
- this.valueHash = 0;
- }
-
- /**
- * @return An Optional with the given value.
- * @throws NullPointerException if the value is null
- */
- public static <T> Optional<T> of(final T value) throws NullPointerException {
- if (null == value) {
- throw new NullPointerException("Passed a null value. Use ofNullable() instead");
- }
- return new Optional<>(value);
- }
-
- /**
- * @return an Optional with no value.
- */
- public static <T> Optional<T> empty() {
- return new Optional<>();
- }
-
- /**
- * @return An optional representing the given value, or an empty Optional.
- */
- public static <T> Optional<T> ofNullable(final T value) {
- if (null == value) {
- return Optional.empty();
- } else {
- return Optional.of(value);
- }
- }
-
- /**
- * @return the value represented or null, if isPresent() is false.
- */
- public T get() {
- return this.value;
- }
-
- /**
- * @param other
- * @return the value of this Optional or other, if no value exists.
- */
- public T orElse(final T other) {
- if (isPresent()) {
- return this.get();
- } else {
- return other;
- }
- }
-
- /**
- * @return true if there is a value, false otherwise.
- */
- public boolean isPresent() {
- return null != this.value;
- }
-
- @Override
- public boolean equals(final Object obj) {
-
- if (this == obj) return true;
-
- if (obj == null || getClass() != obj.getClass()) return false;
-
- final Optional that = (Optional) obj;
- return this.value == that.value || (this.value != null && this.value.equals(that.value));
- }
-
- @Override
- public int hashCode() {
- return this.valueHash;
- }
-
- @Override
- public String toString() {
- return this.valueStr;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/util/SetOnce.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/util/SetOnce.java b/reef-common/src/main/java/com/microsoft/reef/util/SetOnce.java
deleted file mode 100644
index 2103383..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/util/SetOnce.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.util;
-
-/**
- * A reference to a value that can be set exactly once.
- */
-public final class SetOnce<T> {
-
- private Optional<T> value;
-
- public SetOnce(final T value) {
- this.set(value);
- }
-
- public SetOnce() {
- this.value = Optional.empty();
- }
-
- public synchronized T get() {
- return value.get();
- }
-
- public synchronized void set(final T value) {
- if (this.value.isPresent()) {
- throw new IllegalStateException("Trying to set new value " + value +
- " while an old value was already present: " + this.value);
- }
- this.value = Optional.of(value);
- }
-
- public synchronized boolean isSet() {
- return this.value.isPresent();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/util/SingletonAsserter.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/util/SingletonAsserter.java b/reef-common/src/main/java/com/microsoft/reef/util/SingletonAsserter.java
deleted file mode 100644
index 8091ac7..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/util/SingletonAsserter.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.util;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * A helper class that can be used to ensure that objects are only instantiated once.
- */
-public final class SingletonAsserter {
-
- private static final Set<Class> classes = Collections.synchronizedSet(new HashSet<Class>());
-
- /**
- * This class operates purely in static mode.
- */
- private SingletonAsserter() {
- }
-
- public static boolean assertSingleton(final Class clazz) {
- return classes.add(clazz);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/util/logging/Config.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/util/logging/Config.java b/reef-common/src/main/java/com/microsoft/reef/util/logging/Config.java
deleted file mode 100644
index 48fdd0a..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/util/logging/Config.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.util.logging;
-
-import java.io.IOException;
-import java.util.logging.LogManager;
-
-public final class Config {
-
- public Config() throws IOException {
- LogManager.getLogManager().readConfiguration(
- Thread.currentThread().getContextClassLoader()
- .getResourceAsStream("com/microsoft/reef/logging.properties"));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/util/logging/LoggingSetup.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/util/logging/LoggingSetup.java b/reef-common/src/main/java/com/microsoft/reef/util/logging/LoggingSetup.java
deleted file mode 100644
index d656a6b..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/util/logging/LoggingSetup.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.util.logging;
-
-/**
- * Configure Commons Logging
- */
-public final class LoggingSetup {
-
- private LoggingSetup() {
- }
-
- /**
- * Redirect the commons logging to the JDK logger.
- */
- public static void setupCommonsLogging() {
- if (System.getProperty("org.apache.commons.logging.Log") == null) {
- System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Jdk14Logger");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/util/logging/ThreadLogFormatter.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/util/logging/ThreadLogFormatter.java b/reef-common/src/main/java/com/microsoft/reef/util/logging/ThreadLogFormatter.java
deleted file mode 100644
index ff293de..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/util/logging/ThreadLogFormatter.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-package com.microsoft.reef.util.logging;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.logging.Formatter;
-import java.util.logging.LogManager;
-import java.util.logging.LogRecord;
-
-/**
- * A denser logging format for REEF that is similar to the standard SimpleFormatter.
- *
- * The following config properties are available:
- *
- * * `com.microsoft.reef.util.logging.ThreadLogFormatter.format`
- * is a format string for String.format() that takes same arguments and in
- * the same order as the standard SimpleFormatter, plus the thread name:
- * 1. date
- * 2. class and method name
- * 3. logger name
- * 4. logging level
- * 5. message
- * 6. stack trace
- * 7. thread name
- *
- * * `com.microsoft.reef.util.logging.ThreadLogFormatter.dropPrefix`
- * contains a comma-separated list of package name prefixes that should be
- * removed from the class name for logging. e.g. value `com.microsoft.,org.apache.`
- * will have the formatter write class `com.microsoft.reef.util.logging.Config` as
- * `reef.util.logging.Config`. (Note the dot at the end of the prefix).
- */
-public final class ThreadLogFormatter extends Formatter {
-
- private static final String DEFAULT_FORMAT = "%1$tF %1$tT,%1$tL %4$s %2$s %7$s | %5$s%6$s%n";
-
- private final List<String> dropPrefix = new ArrayList<>();
- private final Date date = new Date();
- private final String logFormat;
-
- public ThreadLogFormatter() {
-
- super();
- final LogManager logManager = LogManager.getLogManager();
- final String className = this.getClass().getName();
-
- final String format = logManager.getProperty(className + ".format");
- this.logFormat = format != null ? format : DEFAULT_FORMAT;
-
- final String rawDropStr = logManager.getProperty(className + ".dropPrefix");
- if (rawDropStr != null) {
- for (String prefix : rawDropStr.trim().split(",")) {
- prefix = prefix.trim();
- if (!prefix.isEmpty()) {
- this.dropPrefix.add(prefix);
- }
- }
- }
- }
-
- /**
- * Format the log string. Internally, it uses `String.format()` that takes same
- * arguments and in the same order as the standard SimpleFormatter, plus the thread name:
- * 1. date
- * 2. class and method name
- * 3. logger name
- * 4. logging level
- * 5. message
- * 6. stack trace
- * 7. thread name
- *
- * @return string to be written to the log.
- */
- @Override
- public String format(final LogRecord logRecord) {
- this.date.setTime(System.currentTimeMillis());
- return String.format(
- this.logFormat,
- this.date,
- this.trimPrefix(logRecord.getSourceClassName()) + "." + logRecord.getSourceMethodName(),
- logRecord.getLoggerName(),
- logRecord.getLevel().getLocalizedName(),
- formatMessage(logRecord),
- this.getStackTrace(logRecord.getThrown()),
- Thread.currentThread().getName());
- }
-
- /**
- * Check if the class name starts with one of the prefixes specified in `dropPrefix`,
- * and remove it. e.g. for class name `com.microsoft.reef.util.logging.Config` and
- * prefix `com.microsoft.` (note the trailing dot), the result will be
- * `reef.util.logging.Config`
- */
- private String trimPrefix(final String className) {
- for (final String prefix : this.dropPrefix) {
- if (className.startsWith(prefix)) {
- return className.substring(prefix.length());
- }
- }
- return className;
- }
-
- /**
- * @return a string that contains stack trace of a given exception.
- * if `error` is null, return an empty string.
- */
- private String getStackTrace(final Throwable error) {
- if (error != null) {
- try (final StringWriter sw = new StringWriter();
- final PrintWriter pw = new PrintWriter(sw)) {
- pw.println();
- error.printStackTrace(pw);
- return sw.toString();
- } catch (final IOException ex) {
- // should never happen
- throw new RuntimeException("Unexpected error while logging stack trace", ex);
- }
- }
- return "";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/com/microsoft/reef/util/package-info.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/com/microsoft/reef/util/package-info.java b/reef-common/src/main/java/com/microsoft/reef/util/package-info.java
deleted file mode 100644
index 30086cd..0000000
--- a/reef-common/src/main/java/com/microsoft/reef/util/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * 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.
- */
-/**
- * Various utility classes.
- */
-package com.microsoft.reef.util;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/client/ClientConfiguration.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/client/ClientConfiguration.java b/reef-common/src/main/java/org/apache/reef/client/ClientConfiguration.java
new file mode 100644
index 0000000..9eeded4
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/client/ClientConfiguration.java
@@ -0,0 +1,81 @@
+/**
+ * Copyright (C) 2014 Microsoft Corporation
+ *
+ * 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.
+ */
+package org.apache.reef.client;
+
+import org.apache.reef.client.parameters.*;
+import org.apache.reef.runtime.common.client.parameters.ClientPresent;
+import org.apache.reef.tang.formats.ConfigurationModule;
+import org.apache.reef.tang.formats.ConfigurationModuleBuilder;
+import org.apache.reef.tang.formats.OptionalImpl;
+import org.apache.reef.wake.EventHandler;
+import org.apache.reef.wake.remote.RemoteConfiguration;
+
+/**
+ * A ConfigurationModule to fill out for the client configuration.
+ */
+public final class ClientConfiguration extends ConfigurationModuleBuilder {
+
+ /**
+ * Event handler for messages from the running job.
+ * Default implementation just writes message to the log.
+ * A message contains a status and a client-defined message payload.
+ */
+ public static final OptionalImpl<EventHandler<JobMessage>> ON_JOB_MESSAGE = new OptionalImpl<>();
+
+ /**
+ * Handler for the event when a submitted REEF Job is running.
+ * Default implementation just writes to the log.
+ */
+ public static final OptionalImpl<EventHandler<RunningJob>> ON_JOB_RUNNING = new OptionalImpl<>();
+
+ /**
+ * Handler for the event when a submitted REEF Job is completed.
+ * Default implementation just writes to the log.
+ */
+ public static final OptionalImpl<EventHandler<CompletedJob>> ON_JOB_COMPLETED = new OptionalImpl<>();
+
+ /**
+ * Handler for the event when a submitted REEF Job has failed.
+ * Default implementation logs an error and rethrows the exception in the client JVM.
+ */
+ public static final OptionalImpl<EventHandler<FailedJob>> ON_JOB_FAILED = new OptionalImpl<>();
+
+ /**
+ * Receives fatal resourcemanager errors. The presence of this error means that the
+ * underlying REEF instance is no longer able to execute REEF jobs. The
+ * actual Jobs may or may not still be running.
+ * Default implementation logs an error and rethrows the exception in the client JVM.
+ */
+ public static final OptionalImpl<EventHandler<FailedRuntime>> ON_RUNTIME_ERROR = new OptionalImpl<>();
+
+ /**
+ * Error handler for events on Wake-spawned threads.
+ * Exceptions that are thrown on wake-spawned threads (e.g. in EventHandlers) will be caught by Wake and delivered to
+ * this handler. Default behavior is to log the exceptions and rethrow them as RuntimeExceptions.
+ */
+ public static final OptionalImpl<EventHandler<Throwable>> ON_WAKE_ERROR = new OptionalImpl<>();
+
+ public static final ConfigurationModule CONF = new ClientConfiguration()
+ .bind(JobMessageHandler.class, ON_JOB_MESSAGE)
+ .bind(JobRunningHandler.class, ON_JOB_RUNNING)
+ .bind(JobCompletedHandler.class, ON_JOB_COMPLETED)
+ .bind(JobFailedHandler.class, ON_JOB_FAILED)
+ .bind(ResourceManagerErrorHandler.class, ON_RUNTIME_ERROR)
+ .bindNamedParameter(ClientPresent.class, ClientPresent.YES)
+ .bindNamedParameter(RemoteConfiguration.ErrorHandler.class, ON_WAKE_ERROR)
+ .bindNamedParameter(RemoteConfiguration.ManagerName.class, "REEF_CLIENT")
+ .build();
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/client/CompletedJob.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/client/CompletedJob.java b/reef-common/src/main/java/org/apache/reef/client/CompletedJob.java
new file mode 100644
index 0000000..2c0c732
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/client/CompletedJob.java
@@ -0,0 +1,36 @@
+/**
+ * Copyright (C) 2014 Microsoft Corporation
+ *
+ * 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.
+ */
+package org.apache.reef.client;
+
+import org.apache.reef.annotations.Provided;
+import org.apache.reef.annotations.audience.ClientSide;
+import org.apache.reef.annotations.audience.Public;
+import org.apache.reef.io.naming.Identifiable;
+
+/**
+ * Represents a completed REEF job.
+ */
+@Public
+@ClientSide
+@Provided
+public interface CompletedJob extends Identifiable {
+
+ /**
+ * @return the ID of the completed job.
+ */
+ @Override
+ public String getId();
+}