http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Source/REEF/reef-common/ReefDriver/EvaluatorManager.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/EvaluatorManager.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/EvaluatorManager.cs deleted file mode 100644 index 5dc1ce7..0000000 --- a/lang/cs/Source/REEF/reef-common/ReefDriver/EvaluatorManager.cs +++ /dev/null @@ -1,655 +0,0 @@ -/** - * 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. - */ - -using Org.Apache.Reef.Common.Api; -using Org.Apache.Reef.Common.Catalog; -using Org.Apache.Reef.Common.Evaluator; -using Org.Apache.Reef.Common.Exceptions; -using Org.Apache.Reef.Common.ProtoBuf.DriverRuntimeProto; -using Org.Apache.Reef.Common.ProtoBuf.EvaluatorRunTimeProto; -using Org.Apache.Reef.Common.ProtoBuf.ReefServiceProto; -using Org.Apache.Reef.Driver.Bridge; -using Org.Apache.Reef.Driver.Context; -using Org.Apache.Reef.Driver.Evaluator; -using Org.Apache.Reef.Driver.Task; -using Org.Apache.Reef.Utilities; -using Org.Apache.Reef.Utilities.Diagnostics; -using Org.Apache.Reef.Utilities.Logging; -using Org.Apache.Reef.Tang.Annotations; -using Org.Apache.Reef.Wake.Remote; -using Org.Apache.Reef.Wake.Time; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text; - -using TaskMessage = Org.Apache.Reef.Tasks.TaskMessage; - -namespace Org.Apache.Reef.Driver -{ - /// <summary> - /// Manages a single Evaluator instance including all lifecycle instances: - /// (AllocatedEvaluator, CompletedEvaluator, FailedEvaluator). - /// A (periodic) heartbeat channel is established EvaluatorRuntime -> EvaluatorManager. - /// The EvaluatorRuntime will (periodically) send (status) messages to the EvaluatorManager using this heartbeat channel. - /// A (push-based) EventHandler channel is established EvaluatorManager -> EvaluatorRuntime. - /// The EvaluatorManager uses this to forward Driver messages, launch Tasks, and initiate - /// control information (e.g., shutdown, suspend).* Manages a single Evaluator instance including all lifecycle instances: - /// (AllocatedEvaluator, CompletedEvaluator, FailedEvaluator). - /// A (periodic) heartbeat channel is established EvaluatorRuntime -> EvaluatorManager. - /// The EvaluatorRuntime will (periodically) send (status) messages to the EvaluatorManager using this heartbeat channel. - /// A (push-based) EventHandler channel is established EvaluatorManager -> EvaluatorRuntime. - /// The EvaluatorManager uses this to forward Driver messages, launch Tasks, and initiate control information (e.g., shutdown, suspend). - /// </summary> - public class EvaluatorManager : IDisposable, IIdentifiable - { - private static readonly Logger LOGGER = Logger.GetLogger(typeof(EvaluatorManager)); - - private STATE _state = STATE.ALLOCATED; - - private IClock _clock; - - // TODO - // private final RemoteManager remoteManager; - private DriverManager _driverManager; - - private IResourceReleaseHandler _resourceReleaseHandler; - - private IResourceLaunchHandler _resourceLaunchHandler; - - private EvaluatorDescriptorImpl _evaluatorDescriptor; - - private string _evaluatorId; - - private IList<EvaluatorContext> _activeContexts = new List<EvaluatorContext>(); - - private HashSet<string> _activeContextIds = new HashSet<string>(); - - private IRunningTask _runningTask = null; - - private IObserver<EvaluatorControlProto> _evaluatorControlHandler = null; - - private bool _isResourceReleased = false; - - //TODO - //private final DispatchingEStage dispatcher; - private EvaluatorType _type = EvaluatorType.CLR; - - public EvaluatorManager( - IClock clock, - //RemoteManager remoteManager, - DriverManager driverManager, - IResourceReleaseHandler resourceReleaseHandler, - IResourceLaunchHandler resourceLaunchHandler, - //REEFErrorHandler errorHandler, - string evaluatorId, - EvaluatorDescriptorImpl evaluatorDescriptor, - ISet<IObservable<IActiveContext>> activeContextEventHandler, - ISet<IObservable<IClosedContext>> closedContextEventHandlers, - ISet<IObservable<FailedContext>> failedContextEventHandlers, - ISet<IObservable<ContextMessage>> contextMessageHandlers, - ISet<IObservable<IRunningTask>> runningTaskEventHandlers, - ISet<IObservable<ICompletedTask>> completedTaskEventHandlers, - ISet<IObservable<ISuspendedTask>> suspendedTaskEventHandlers, - ISet<IObservable<TaskMessage>> taskMessageEventHandlers, - ISet<IObservable<FailedTask>> taskExceptionEventHandlers, - ISet<IObservable<IAllocatedEvaluator>> allocatedEvaluatorEventHandlers, - ISet<IObservable<IFailedEvaluator>> failedEvaluatorHandlers, - ISet<IObservable<ICompletedEvaluator>> completedEvaluatorHandlers) - { - _clock = clock; - //_remoteManager = remoteManager; - _driverManager = driverManager; - _resourceReleaseHandler = resourceReleaseHandler; - _resourceLaunchHandler = resourceLaunchHandler; - _evaluatorId = evaluatorId; - _evaluatorDescriptor = evaluatorDescriptor; - - //this.dispatcher = new DispatchingEStage(errorHandler, 16); // 16 threads - - //this.dispatcher.register(ActiveContext.class, activeContextEventHandlers); - //this.dispatcher.register(ClosedContext.class, closedContextEventHandlers); - //this.dispatcher.register(FailedContext.class, failedContextEventHandlers); - //this.dispatcher.register(ContextMessage.class, contextMessageHandlers); - - //this.dispatcher.register(RunningTask.class, runningTaskEventHandlers); - //this.dispatcher.register(CompletedTask.class, completedTaskEventHandlers); - //this.dispatcher.register(SuspendedTask.class, suspendedTaskEventHandlers); - //this.dispatcher.register(TaskMessage.class, taskMessageEventHandlers); - //this.dispatcher.register(FailedTask.class, taskExceptionEventHandlers); - - //this.dispatcher.register(FailedEvaluator.class, failedEvaluatorHandlers); - //this.dispatcher.register(CompletedEvaluator.class, completedEvaluatorHandlers); - //this.dispatcher.register(AllocatedEvaluator.class, allocatedEvaluatorEventHandlers); - - //this.dispatcher.onNext(AllocatedEvaluator.class, - // new AllocatedEvaluatorImpl(this, remoteManager.getMyIdentifier())); - } - - /// <summary> - /// Various states that the EvaluatorManager could be in. The EvaluatorManager is created when a resource has been allocated by the ResourceManager. - /// </summary> - public enum STATE - { - ALLOCATED, // initial state - SUBMITTED, // client called AllocatedEvaluator.submitTask() and we're waiting for first contact - RUNNING, // first contact received, all communication channels established, Evaluator sent to client. - DONE, // clean shutdown - FAILED, // some failure occurred. - KILLED // unclean shutdown - } - - public IEvaluatorDescriptor EvaluatorDescriptor - { - get - { - return _evaluatorDescriptor; - } - } - - public INodeDescriptor NodeDescriptor - { - get - { - return EvaluatorDescriptor.NodeDescriptor; - } - } - - public IRunningTask RunningTask - { - get - { - lock (_evaluatorDescriptor) - { - return _runningTask; - } - } - } - - public string Id - { - get - { - return _evaluatorId; - } - - set - { - } - } - - public EvaluatorType Type - { - get - { - return _type; - } - - set - { - _type = value; - _evaluatorDescriptor.EvaluatorType = value; - } - } - - public void Dispose() - { - lock (_evaluatorDescriptor) - { - if (_state == STATE.RUNNING) - { - LOGGER.Log(Level.Warning, "Dirty shutdown of running evaluator :" + Id); - try - { - // Killing the evaluator means that it doesn't need to send a confirmation; it just dies. - EvaluatorControlProto proto = new EvaluatorControlProto(); - proto.timestamp = DateTime.Now.Ticks; - proto.identifier = Id; - proto.kill_evaluator = new KillEvaluatorProto(); - Handle(proto); - } - finally - { - _state = STATE.KILLED; - } - } - } - - if (!_isResourceReleased) - { - try - { - // We need to wait awhile before returning the container to the RM in order to - // give the EvaluatorRuntime (and Launcher) time to cleanly exit. - - // this.clock.scheduleAlarm(100, new EventHandler<Alarm>() { - //@Override - //public void onNext(final Alarm alarm) { - // EvaluatorManager.this.resourceReleaseHandler.onNext( - // DriverRuntimeProtocol.ResourceReleaseProto.newBuilder() - // .setIdentifier(EvaluatorManager.this.evaluatorId).build()); - } - catch (Exception e) - { - Exceptions.Caught(e, Level.Warning, "Force resource release because the client closed the clock.", LOGGER); - ResourceReleaseProto proto = new ResourceReleaseProto(); - proto.identifier = _evaluatorId; - _resourceReleaseHandler.OnNext(proto); - } - finally - { - _isResourceReleased = true; - _driverManager.Release(this); - } - } - } - - /// <summary> - /// EvaluatorException will trigger is FailedEvaluator and state transition to FAILED - /// </summary> - /// <param name="exception"></param> - public void Handle(EvaluatorException exception) - { - lock (_evaluatorDescriptor) - { - if (_state >= STATE.DONE) - { - return; - } - LOGGER.Log(Level.Warning, "Failed Evaluator: " + Id + exception.Message); - try - { - IList<FailedContext> failedContexts = new List<FailedContext>(); - IList<EvaluatorContext> activeContexts = new List<EvaluatorContext>(_activeContexts); - activeContexts = activeContexts.Reverse().ToList(); - foreach (EvaluatorContext context in activeContexts) - { - Optional<IActiveContext> parentContext = context.ParentId.IsPresent() - ? Optional<IActiveContext>.Of(GetEvaluatorContext(context.ParentId.Value)) - : Optional<IActiveContext>.Empty(); - failedContexts.Add(context.GetFailedContext(parentContext, exception)); - } - - //Optional<FailedTask> failedTask = _runningTask != null ? - // Optional<FailedTask>.Of(new FailedTask(_runningTask.Id, exception)) : Optional<FailedTask>.Empty(); - //LOGGER.Log(Level.Info, "TODO: REPLACE THIS " + failedTask.ToString()); - //this.dispatcher.onNext(FailedEvaluator.class, new FailedEvaluatorImpl( - //exception, failedContextList, failedTaskOptional, this.evaluatorId)); - } - catch (Exception e) - { - Exceptions.CaughtAndThrow(e, Level.Error, "Exception while handling FailedEvaluator.", LOGGER); - } - finally - { - _state = STATE.FAILED; - Dispose(); - } - } - } - - public void Handle(IRemoteMessage<EvaluatorHeartbeatProto> evaluatorHearBeatProtoMessage) - { - lock (_evaluatorDescriptor) - { - EvaluatorHeartbeatProto heartbeatProto = evaluatorHearBeatProtoMessage.Message; - if (heartbeatProto.evaluator_status != null) - { - EvaluatorStatusProto status = heartbeatProto.evaluator_status; - if (status.error != null) - { - Handle(new EvaluatorException(Id, ByteUtilities.ByteArrarysToString(status.error))); - return; - } - else if (_state == STATE.SUBMITTED) - { - string evaluatorRId = evaluatorHearBeatProtoMessage.Identifier.ToString(); - LOGGER.Log(Level.Info, "TODO: REPLACE THIS " + evaluatorRId); - // TODO - // _evaluatorControlHandler = _remoteManager.getHandler(evaluatorRID, EvaluatorRuntimeProtocol.EvaluatorControlProto.class); - _state = STATE.RUNNING; - LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Evaluator {0} is running", _evaluatorId)); - } - } - - LOGGER.Log(Level.Info, "Evaluator heartbeat: " + heartbeatProto); - - EvaluatorStatusProto evaluatorStatusProto = heartbeatProto.evaluator_status; - foreach (ContextStatusProto contextStatusProto in heartbeatProto.context_status) - { - Handle(contextStatusProto, heartbeatProto.task_status != null); - } - - if (heartbeatProto.task_status != null) - { - Handle(heartbeatProto.task_status); - } - - if (evaluatorStatusProto.state == State.FAILED) - { - _state = STATE.FAILED; - EvaluatorException e = evaluatorStatusProto.error != null ? - new EvaluatorException(_evaluatorId, ByteUtilities.ByteArrarysToString(evaluatorStatusProto.error)) : - new EvaluatorException(_evaluatorId, "unknown cause"); - LOGGER.Log(Level.Warning, "Failed evaluator: " + Id + e.Message); - Handle(e); - } - else if (evaluatorStatusProto.state == State.DONE) - { - LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Evaluator {0} done", Id)); - _state = STATE.DONE; - - // TODO - // dispatcher.onNext(CompletedEvaluator.class, new CompletedEvaluator() { - //@Override - //public String getId() { - // return EvaluatorManager.this.evaluatorId; - Dispose(); - } - } - LOGGER.Log(Level.Info, "DONE with evaluator heartbeat"); - } - - public void Handle(ResourceLaunchProto resourceLaunchProto) - { - lock (_evaluatorDescriptor) - { - if (_state == STATE.ALLOCATED) - { - _state = STATE.SUBMITTED; - _resourceLaunchHandler.OnNext(resourceLaunchProto); - } - else - { - var e = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Evaluator manager expected {0} state, but instead is in state {1}", STATE.ALLOCATED, _state)); - Exceptions.Throw(e, LOGGER); - } - } - } - - /// <summary> - /// Packages the TaskControlProto in an EvaluatorControlProto and forward it to the EvaluatorRuntime - /// </summary> - /// <param name="contextControlProto"></param> - public void Handle(ContextControlProto contextControlProto) - { - lock (_evaluatorDescriptor) - { - LOGGER.Log(Level.Info, "Task control message from " + _evaluatorId); - EvaluatorControlProto evaluatorControlProto = new EvaluatorControlProto(); - evaluatorControlProto.timestamp = DateTime.Now.Ticks; - evaluatorControlProto.identifier = Id; - evaluatorControlProto.context_control = contextControlProto; - - Handle(evaluatorControlProto); - } - } - - /// <summary> - /// Forward the EvaluatorControlProto to the EvaluatorRuntime - /// </summary> - /// <param name="proto"></param> - public void Handle(EvaluatorControlProto proto) - { - lock (_evaluatorDescriptor) - { - if (_state == STATE.RUNNING) - { - _evaluatorControlHandler.OnNext(proto); - } - else - { - var e = new InvalidOperationException( - string.Format( - CultureInfo.InvariantCulture, - "Evaluator manager expects to be in {0} state, but instead is in state {1}", - STATE.RUNNING, - _state)); - Exceptions.Throw(e, LOGGER); - } - } - } - - /// <summary> - /// Resource status information from the (actual) resource manager. - /// </summary> - /// <param name="resourceStatusProto"></param> - public void Handle(ResourceStatusProto resourceStatusProto) - { - lock (_evaluatorDescriptor) - { - State resourceState = resourceStatusProto.state; - LOGGER.Log(Level.Info, "Resource manager state update: " + resourceState); - - if (resourceState == State.DONE || resourceState == State.FAILED) - { - if (_state < STATE.DONE) - { - // something is wrong, I think I'm alive but the resource manager runtime says I'm dead - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.Append( - string.Format( - CultureInfo.InvariantCulture, - "The resource manager informed me that Evaluator {0} is in state {1} but I think I am in {2} state", - _evaluatorId, - resourceState, - _state)); - if (resourceStatusProto.diagnostics != null) - { - stringBuilder.Append("Cause: " + resourceStatusProto.diagnostics); - } - if (_runningTask != null) - { - stringBuilder.Append( - string.Format( - CultureInfo.InvariantCulture, - "Taskruntime {0} did not complete before this evaluator died.", - _runningTask.Id)); - } - - // RM is telling me its DONE/FAILED - assuming it has already released the resources - _isResourceReleased = true; - //Handle(new EvaluatorException(_evaluatorId, stringBuilder.ToString(), _runningTask)); - _state = STATE.KILLED; - } - } - } - } - - /// <summary> - /// Handle a context status update - /// </summary> - /// <param name="contextStatusProto"></param> - /// <param name="notifyClientOnNewActiveContext"></param> - private void Handle(ContextStatusProto contextStatusProto, bool notifyClientOnNewActiveContext) - { - string contextId = contextStatusProto.context_id; - Optional<string> parentId = contextStatusProto.parent_id != null ? - Optional<string>.Of(contextStatusProto.parent_id) : Optional<string>.Empty(); - if (ContextStatusProto.State.READY == contextStatusProto.context_state) - { - if (!_activeContextIds.Contains(contextId)) - { - EvaluatorContext evaluatorContext = new EvaluatorContext(this, contextId, parentId); - AddEvaluatorContext(evaluatorContext); - if (notifyClientOnNewActiveContext) - { - LOGGER.Log(Level.Info, "TODO: REPLACE THIS " + evaluatorContext.ToString()); - //TODO - //dispatcher.onNext(ActiveContext.class, context); - } - } - foreach (ContextStatusProto.ContextMessageProto contextMessageProto in contextStatusProto.context_message) - { - byte[] message = contextMessageProto.message; - string sourceId = contextMessageProto.source_id; - LOGGER.Log(Level.Info, "TODO: REPLACE THIS " + sourceId + message); - // this.dispatcher.onNext(ContextMessage.class, - //new ContextMessageImpl(theMessage, contextID, sourceID)); - } - } - else - { - if (!_activeContextIds.Contains(contextId)) - { - if (ContextStatusProto.State.FAIL == contextStatusProto.context_state) - { - AddEvaluatorContext(new EvaluatorContext(this, contextId, parentId)); - } - else - { - var e = new InvalidOperationException("unknown context signaling state " + contextStatusProto.context_state); - Exceptions.Throw(e, LOGGER); - } - } - } - - EvaluatorContext context = GetEvaluatorContext(contextId); - EvaluatorContext parentContext = context.ParentId.IsPresent() ? - GetEvaluatorContext(context.ParentId.Value) : null; - RemoveEvaluatorContext(context); - - if (ContextStatusProto.State.FAIL == contextStatusProto.context_state) - { - // TODO - Exception reason = new InvalidOperationException(ByteUtilities.ByteArrarysToString(contextStatusProto.error)); - Optional<IActiveContext> optionalParentContext = (null == parentContext) ? - Optional<IActiveContext>.Empty() : Optional<IActiveContext>.Of(parentContext); - LOGGER.Log(Level.Info, "TODO: REPLACE THIS " + reason.ToString() + optionalParentContext); - // TODO - //this.dispatcher.onNext(FailedContext.class, - //context.getFailedContext(optionalParentContext, reason)); - } - else if (ContextStatusProto.State.DONE == contextStatusProto.context_state) - { - if (null != parentContext) - { - // TODO - //this.dispatcher.onNext(ClosedContext.class, context.getClosedContext(parentContext)); - } - else - { - LOGGER.Log(Level.Info, "Root context closed. Evaluator closed will trigger final shutdown."); - } - } - else - { - var e = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Unknown context state {0} for context {1}", contextStatusProto.context_state, contextId)); - Exceptions.Throw(e, LOGGER); - } - } - - /// <summary> - /// Handle task status messages. - /// </summary> - /// <param name="taskStatusProto"></param> - private void Handle(TaskStatusProto taskStatusProto) - { - LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Received task {0} status {1}", taskStatusProto.task_id, taskStatusProto.state)); - string taskId = taskStatusProto.task_id; - string contextId = taskStatusProto.context_id; - State taskState = taskStatusProto.state; - - if (taskState == State.INIT) - { - EvaluatorContext evaluatorContext = GetEvaluatorContext(contextId); - _runningTask = new RunningTaskImpl(this, taskId, evaluatorContext); - // this.dispatcher.onNext(RunningTask.class, this.runningTask); - } - else if (taskState == State.SUSPEND) - { - EvaluatorContext evaluatorContext = GetEvaluatorContext(contextId); - _runningTask = null; - byte[] message = taskStatusProto.result != null ? taskStatusProto.result : null; - LOGGER.Log(Level.Info, "TODO: REPLACE THIS " + evaluatorContext + message.ToString()); - //this.dispatcher.onNext(SuspendedTask.class, new SuspendedTaskImpl(evaluatorContext, message, taskId)); - } - else if (taskState == State.DONE) - { - EvaluatorContext evaluatorContext = GetEvaluatorContext(contextId); - _runningTask = null; - byte[] message = taskStatusProto.result != null ? taskStatusProto.result : null; - LOGGER.Log(Level.Info, "TODO: REPLACE THIS " + evaluatorContext + message.ToString()); - //this.dispatcher.onNext(CompletedTask.class, new CompletedTaskImpl(evaluatorContext, message, taskId)); - } - else if (taskState == State.FAILED) - { - _runningTask = null; - //EvaluatorContext evaluatorContext = GetEvaluatorContext(contextId); - //FailedTask failedTask = taskStatusProto.result != null ? - // new FailedTask(taskId, ByteUtilities.ByteArrarysToString(taskStatusProto.result), Optional<IActiveContext>.Of(evaluatorContext)) : - // new FailedTask(taskId, "Failed task: " + taskState, Optional<IActiveContext>.Of(evaluatorContext)); - //LOGGER.Log(Level.Info, "TODO: REPLACE THIS " + failedTask.ToString()); - //this.dispatcher.onNext(FailedTask.class, taskException); - } - else if (taskStatusProto.task_message.Count > 0) - { - if (_runningTask != null) - { - var e = new InvalidOperationException("runningTask must be null when there are multiple task messages"); - Exceptions.Throw(e, LOGGER); - } - foreach (TaskStatusProto.TaskMessageProto taskMessageProto in taskStatusProto.task_message) - { - LOGGER.Log(Level.Info, "TODO: REPLACE THIS " + taskMessageProto.ToString()); - // this.dispatcher.onNext(TaskMessage.class, - //new TaskMessageImpl(taskMessageProto.getMessage().toByteArray(), - // taskId, contextId, taskMessageProto.getSourceId())); - } - } - } - - private EvaluatorContext GetEvaluatorContext(string id) - { - foreach (EvaluatorContext context in _activeContexts) - { - if (context.Id.Equals(id)) - { - return context; - } - var e = new InvalidOperationException("Unknown evaluator context with id " + id); - Exceptions.Throw(e, LOGGER); - } - return null; - } - - private void AddEvaluatorContext(EvaluatorContext context) - { - _activeContexts.Add(context); - _activeContextIds.Add(context.Id); - } - - private void RemoveEvaluatorContext(EvaluatorContext context) - { - _activeContexts.Remove(context); - _activeContextIds.Remove(context.Id); - } - - [NamedParameter(documentation: "The Evaluator Identifier.")] - public class EvaluatorIdentifier : Name<string> - { - } - - [NamedParameter(documentation: "The Evaluator Host.")] - public class EvaluatorDescriptorName : Name<EvaluatorDescriptorImpl> - { - } - } -}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Source/REEF/reef-common/ReefDriver/FailedJob.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/FailedJob.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/FailedJob.cs deleted file mode 100644 index b0cde11..0000000 --- a/lang/cs/Source/REEF/reef-common/ReefDriver/FailedJob.cs +++ /dev/null @@ -1,51 +0,0 @@ -/** - * 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. - */ - -using Org.Apache.Reef.Common.Api; -using Org.Apache.Reef.Utilities; -using System; - -namespace Org.Apache.Reef.Driver -{ - /// <summary> - /// An error message that REEF Client receives when there is a user error in REEF job. - /// </summary> - public class FailedJob : AbstractFailure - { - /// <summary> - /// Create an error message given the entity ID and Java Exception. All accessor methods are provided by the base class. - /// </summary> - /// <param name="id"></param> - /// <param name="cause"></param> - public FailedJob(string id, Exception cause) - : base(id, cause) - { - } - - public new string Id { get; set; } - - public new string Message { get; set; } - - public new Optional<string> Description { get; set; } - - public new Optional<Exception> Cause { get; set; } - - public new Optional<byte[]> Data { get; set; } - } -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Source/REEF/reef-common/ReefDriver/IDriver.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/IDriver.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/IDriver.cs deleted file mode 100644 index b0a37dc..0000000 --- a/lang/cs/Source/REEF/reef-common/ReefDriver/IDriver.cs +++ /dev/null @@ -1,28 +0,0 @@ -/** - * 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. - */ - -namespace Org.Apache.Reef.Driver -{ - /// <summary> - /// empty driver interface to facilitate referencing driver dll - /// </summary> - public interface IDriver - { - } -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Source/REEF/reef-common/ReefDriver/IStartHandler.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/IStartHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/IStartHandler.cs deleted file mode 100644 index 64ea1f4..0000000 --- a/lang/cs/Source/REEF/reef-common/ReefDriver/IStartHandler.cs +++ /dev/null @@ -1,26 +0,0 @@ -/** - * 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. - */ - -namespace Org.Apache.Reef.Driver -{ - public interface IStartHandler - { - string Identifier { get; set; } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Source/REEF/reef-common/ReefDriver/Properties/AssemblyInfo.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/Properties/AssemblyInfo.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/Properties/AssemblyInfo.cs deleted file mode 100644 index 14567ae..0000000 --- a/lang/cs/Source/REEF/reef-common/ReefDriver/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,55 +0,0 @@ -/** - * 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. - */ - -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("ReefDriver")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ReefDriver")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("81ea2648-b341-4852-93b0-806da615c6b8")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Source/REEF/reef-common/ReefDriver/ReefDriver.csproj ---------------------------------------------------------------------- diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/ReefDriver.csproj b/lang/cs/Source/REEF/reef-common/ReefDriver/ReefDriver.csproj deleted file mode 100644 index 3f73a0f..0000000 --- a/lang/cs/Source/REEF/reef-common/ReefDriver/ReefDriver.csproj +++ /dev/null @@ -1,226 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -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. ---> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProjectGuid>{A6BAA2A7-F52F-4329-884E-1BCF711D6805}</ProjectGuid> - <OutputType>Library</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>Org.Apache.Reef.Driver</RootNamespace> - <AssemblyName>Org.Apache.Reef.Driver</AssemblyName> - <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> - <FileAlignment>512</FileAlignment> - <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\..</SolutionDir> - <RestorePackages>true</RestorePackages> - </PropertyGroup> - <Import Project="$(SolutionDir)\Source\build.props" /> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <PlatformTarget>AnyCPU</PlatformTarget> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>$(BinDir)\$(Platform)\$(Configuration)\$(RootNamespace)</OutputPath> - <DefineConstants>DEBUG;TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' "> - <PlatformTarget>AnyCPU</PlatformTarget> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>$(BinDir)\$(Platform)\$(Configuration)\$(RootNamespace)</OutputPath> - <DefineConstants>DEBUG;TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <PlatformTarget>AnyCPU</PlatformTarget> - <DebugType>pdbonly</DebugType> - <Optimize>true</Optimize> - <OutputPath>$(BinDir)\$(Platform)\$(Configuration)\$(RootNamespace)</OutputPath> - <DefineConstants>TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' "> - <PlatformTarget>AnyCPU</PlatformTarget> - <DebugType>pdbonly</DebugType> - <Optimize>true</Optimize> - <OutputPath>$(BinDir)\$(Platform)\$(Configuration)\$(RootNamespace)</OutputPath> - <DefineConstants>TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - </PropertyGroup> - <ItemGroup> - <Reference Include="Microsoft.Hadoop.Avro"> - <HintPath>$(PackagesDir)\Microsoft.Hadoop.Avro.1.4.0.0\lib\net40\Microsoft.Hadoop.Avro.dll</HintPath> - </Reference> - <Reference Include="Newtonsoft.Json"> - <HintPath>$(PackagesDir)\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath> - </Reference> - <Reference Include="protobuf-net"> - <HintPath>$(PackagesDir)\protobuf-net.2.0.0.668\lib\net40\protobuf-net.dll</HintPath> - </Reference> - <Reference Include="System" /> - <Reference Include="System.Core" /> - <Reference Include="System.Runtime.Serialization" /> - <Reference Include="System.Xml.Linq" /> - <Reference Include="System.Data.DataSetExtensions" /> - <Reference Include="Microsoft.CSharp" /> - <Reference Include="System.Data" /> - <Reference Include="System.Xml" /> - </ItemGroup> - <ItemGroup> - <Compile Include="bridge\BridgeLogger.cs" /> - <Compile Include="bridge\clr2java\IActiveContextClr2Java.cs" /> - <Compile Include="bridge\clr2java\IAllocatedEvaluaotrClr2Java.cs" /> - <Compile Include="bridge\clr2java\IClosedContextClr2Java.cs" /> - <Compile Include="bridge\clr2java\IClr2Java.cs" /> - <Compile Include="bridge\clr2java\ICompletedEvaluatorClr2Java.cs" /> - <Compile Include="bridge\clr2java\ICompletedTaskClr2Java.cs" /> - <Compile Include="bridge\clr2java\IContextMessageClr2Java.cs" /> - <Compile Include="bridge\clr2java\IEvaluatorRequestorClr2Java.cs" /> - <Compile Include="bridge\clr2java\IFailedContextClr2Java.cs" /> - <Compile Include="bridge\clr2java\IFailedEvaluatorClr2Java.cs" /> - <Compile Include="bridge\clr2java\IFailedTaskClr2Java.cs" /> - <Compile Include="bridge\clr2java\IHttpServerBridgeClr2Java.cs" /> - <Compile Include="bridge\clr2java\IRunningTaskClr2Java.cs" /> - <Compile Include="bridge\clr2java\ISuspendedTaskClr2Java.cs" /> - <Compile Include="bridge\clr2java\ITaskMessageClr2Java.cs" /> - <Compile Include="bridge\ClrClientHelper.cs" /> - <Compile Include="bridge\ClrHandlerHelper.cs" /> - <Compile Include="bridge\ClrSystemHandler.cs" /> - <Compile Include="bridge\ClrSystemHandlerWrapper.cs" /> - <Compile Include="bridge\DriverBridge.cs" /> - <Compile Include="bridge\DriverBridgeConfiguration.cs" /> - <Compile Include="bridge\DriverBridgeConfigurationOptions.cs" /> - <Compile Include="bridge\events\ActiveContext.cs" /> - <Compile Include="bridge\events\AllocatedEvaluator.cs" /> - <Compile Include="bridge\events\ClosedContext.cs" /> - <Compile Include="bridge\events\CompletedEvaluator.cs" /> - <Compile Include="bridge\events\CompletedTask.cs" /> - <Compile Include="bridge\events\ContextMessage.cs" /> - <Compile Include="bridge\events\EvaluatorRequstor.cs" /> - <Compile Include="bridge\events\FailedContext.cs" /> - <Compile Include="bridge\events\FailedEvaluator.cs" /> - <Compile Include="bridge\events\FailedTask.cs" /> - <Compile Include="bridge\events\RunningTask.cs" /> - <Compile Include="bridge\events\SuspendedTask.cs" /> - <Compile Include="bridge\events\TaskMessage.cs" /> - <Compile Include="bridge\HttpMessage.cs" /> - <Compile Include="bridge\HttpServerHandler.cs" /> - <Compile Include="bridge\HttpServerPort.cs" /> - <Compile Include="bridge\IHttpHandler.cs" /> - <Compile Include="bridge\IHttpMessage.cs" /> - <Compile Include="bridge\ReefHttpRequest.cs" /> - <Compile Include="bridge\ReefHttpResponse.cs" /> - <Compile Include="ClientManager.cs" /> - <Compile Include="Constants.cs" /> - <Compile Include="context\ContextConfiguration.cs" /> - <Compile Include="context\ContextConfigurationOptions.cs" /> - <Compile Include="context\defaults\DefaultContextMessageSource.cs" /> - <Compile Include="context\defaults\DefaultContextStartHandler.cs" /> - <Compile Include="context\defaults\DefaultContextStopHandler.cs" /> - <Compile Include="context\EvaluatorContext.cs" /> - <Compile Include="context\IActiveContext.cs" /> - <Compile Include="context\IClosedContext.cs" /> - <Compile Include="context\IContext.cs" /> - <Compile Include="context\IFailedContext.cs" /> - <Compile Include="contract\IBridgeContract.cs" /> - <Compile Include="defaults\DefaultClientCloseHandler.cs" /> - <Compile Include="defaults\DefaultClientCloseWithMessageHandler.cs" /> - <Compile Include="defaults\DefaultClientMessageHandler.cs" /> - <Compile Include="defaults\DefaultContextActiveHandler.cs" /> - <Compile Include="defaults\DefaultContextClosureHandler.cs" /> - <Compile Include="defaults\DefaultContextFailureHandler.cs" /> - <Compile Include="defaults\DefaultContextMessageHandler.cs" /> - <Compile Include="defaults\DefaultCustomTraceListener.cs" /> - <Compile Include="defaults\DefaultDriverRestartContextActiveHandler.cs" /> - <Compile Include="defaults\DefaultDriverRestartHandler.cs" /> - <Compile Include="defaults\DefaultDriverRestartTaskRunningHandler.cs" /> - <Compile Include="defaults\DefaultEvaluatorAllocationHandler.cs" /> - <Compile Include="defaults\DefaultEvaluatorCompletionHandler.cs" /> - <Compile Include="defaults\DefaultEvaluatorFailureHandler.cs" /> - <Compile Include="defaults\DefaultEvaluatorRequestorHandler.cs" /> - <Compile Include="defaults\DefaultHttpHandler.cs" /> - <Compile Include="defaults\DefaultTaskCompletionHandler.cs" /> - <Compile Include="defaults\DefaultTaskFailureHandler.cs" /> - <Compile Include="defaults\DefaultTaskMessageHandler.cs" /> - <Compile Include="defaults\DefaultTaskRunningHandler.cs" /> - <Compile Include="defaults\DefaultTaskSuspensionHandler.cs" /> - <Compile Include="DriverConfigGenerator.cs" /> - <Compile Include="DriverConfigurationSettings.cs" /> - <Compile Include="DriverManager.cs" /> - <Compile Include="DriverRuntimeConfiguration.cs" /> - <Compile Include="DriverRuntimeConfigurationOptions.cs" /> - <Compile Include="DriverSubmissionSettings.cs" /> - <Compile Include="EvaluatorManager.cs" /> - <Compile Include="evaluator\EvaluatorDescriptorImpl.cs" /> - <Compile Include="evaluator\EvaluatorRequest.cs" /> - <Compile Include="evaluator\EvaluatorRequestBuilder.cs" /> - <Compile Include="evaluator\IAllocatedEvaluator.cs" /> - <Compile Include="evaluator\ICompletedEvaluator.cs" /> - <Compile Include="evaluator\IEvaluatorDescriptor.cs" /> - <Compile Include="evaluator\IEvaluatorRequest .cs" /> - <Compile Include="evaluator\IEvaluatorRequestor.cs" /> - <Compile Include="evaluator\IFailedEvaluator.cs" /> - <Compile Include="FailedJob.cs" /> - <Compile Include="IDriver.cs" /> - <Compile Include="IStartHandler.cs" /> - <Compile Include="Properties\AssemblyInfo.cs" /> - <Compile Include="task\ICompletedTask.cs" /> - <Compile Include="task\IFailedTask.cs" /> - <Compile Include="task\IRunningTask.cs" /> - <Compile Include="task\ISuspendedTask.cs" /> - <Compile Include="task\ITaskMessage.cs" /> - <Compile Include="task\RunningTaskImpl.cs" /> - </ItemGroup> - <ItemGroup> - <None Include="packages.config" /> - </ItemGroup> - <ItemGroup> - <ProjectReference Include="$(SourceDir)\Tang\Tang\Tang.csproj"> - <Project>{97dbb573-3994-417a-9f69-ffa25f00d2a6}</Project> - <Name>Tang</Name> - </ProjectReference> - <ProjectReference Include="$(SourceDir)\Utilities\Utilities.csproj"> - <Project>{79e7f89a-1dfb-45e1-8d43-d71a954aeb98}</Project> - <Name>Utilities</Name> - </ProjectReference> - <ProjectReference Include="$(SourceDir)\WAKE\Wake\Wake.csproj"> - <Project>{cdfb3464-4041-42b1-9271-83af24cd5008}</Project> - <Name>Wake</Name> - </ProjectReference> - <ProjectReference Include="$(SourceDir)\Reef\reef-common\ReefCommon\ReefCommon.csproj"> - <Project>{545a0582-4105-44ce-b99c-b1379514a630}</Project> - <Name>ReefCommon</Name> - </ProjectReference> - </ItemGroup> - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> - <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> - --> -</Project> http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/BridgeLogger.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/BridgeLogger.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/BridgeLogger.cs deleted file mode 100644 index 671b82e..0000000 --- a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/BridgeLogger.cs +++ /dev/null @@ -1,65 +0,0 @@ -/** - * 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. - */ - -using System; - -using Org.Apache.Reef.Utilities.Logging; - -namespace Org.Apache.Reef.Driver.Bridge -{ - /// <summary> - /// A wrapper around the general Logger class used specifically for - /// logging in CPP bridge code. - /// This is enabled when trace leve is above Level.Info (included) - /// </summary> - public class BridgeLogger - { - private Logger _logger; - - public BridgeLogger(string name) - { - _logger = Logger.GetLogger(name); - } - - public static BridgeLogger GetLogger(string className) - { - return new BridgeLogger(className); - } - - public void Log(string message) - { - _logger.Log(Level.Info, message); - } - - public void LogStart(string message) - { - _logger.Log(Level.Start, message); - } - - public void LogStop(string message) - { - _logger.Log(Level.Stop, message); - } - - public void LogError(string message, Exception e) - { - _logger.Log(Level.Error, message, e); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrClientHelper.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrClientHelper.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrClientHelper.cs deleted file mode 100644 index 56341d6..0000000 --- a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrClientHelper.cs +++ /dev/null @@ -1,175 +0,0 @@ -/** - * 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. - */ - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using Org.Apache.Reef.Driver.Bridge; -using Org.Apache.Reef.Utilities.Logging; -using Org.Apache.Reef.Tang.Formats; -using Org.Apache.Reef.Tang.Interface; - -namespace Org.Apache.Reef.Driver.bridge -{ - public class ClrClientHelper - { - private static readonly Logger LOGGER = Logger.GetLogger(typeof(ClrClientHelper)); - - public static void Run(HashSet<string> appDlls, IConfiguration driverBridgeConfig, DriverSubmissionSettings driverSubmissionSettings, string reefJar = Constants.BridgeJarFileName, string runCommand = "run.cmd", string clrFolder = ".", string className = Constants.BridgeLaunchClass) - { - using (LOGGER.LogFunction("ClrHandlerHelper::Run")) - { - if (driverSubmissionSettings.Submit) - { - ClrHandlerHelper.CopyDllsToAppDirectory(appDlls); - UpdateJarFileWithAssemblies(reefJar); - } - - using (LOGGER.LogScope("ClrHandlerHelper::serialize driverBridgeConfig to clrRuntimeConfigFile")) - { - string clrRuntimeConfigFile = Path.Combine(clrFolder, Constants.DriverBridgeConfiguration); - new AvroConfigurationSerializer().ToFile(driverBridgeConfig, clrRuntimeConfigFile); - LOGGER.Log(Level.Info, "CLR driver bridge configurations written to " + clrRuntimeConfigFile); - } - - ProcessStartInfo startInfo = new ProcessStartInfo(); - if (driverSubmissionSettings.RunOnYarn) - { - startInfo.FileName = runCommand; - startInfo.Arguments = className + " " + clrFolder + - driverSubmissionSettings.ToComamndLineArguments(); - } - else - { - startInfo.FileName = GetJavaBinary(); - string loggingPrefix = string.Empty; - if (driverSubmissionSettings.JavaLogLevel == JavaLoggingSetting.VERBOSE_TO_CLR) - { - loggingPrefix = Constants.JavaToCLRLoggingConfig + " "; - } - else if (driverSubmissionSettings.JavaLogLevel == JavaLoggingSetting.VERBOSE) - { - loggingPrefix = Constants.JavaVerboseLoggingConfig + " "; - } - startInfo.Arguments = loggingPrefix + @"-classpath " + reefJar + " " + Constants.BridgeLaunchClass + - " " + clrFolder + " " + driverSubmissionSettings.ToComamndLineArguments(); - } - startInfo.RedirectStandardOutput = true; - startInfo.UseShellExecute = false; - startInfo.CreateNoWindow = false; - LOGGER.Log(Level.Info, "Executing\r\n" + startInfo.FileName + "\r\n" + startInfo.Arguments); - using (Process process = Process.Start(startInfo)) - { - process.WaitForExit(); - } - } - } - - public static void UpdateJarFileWithAssemblies(string reefJar) - { - using (LOGGER.LogFunction("ClrHandlerHelper::UpdateJarFileWithAssemblies")) - { - string assembliesList = ClrHandlerHelper.GetAssembliesListForReefDriverApp(); - if (!File.Exists(reefJar)) - { - throw new InvalidOperationException("cannot find reef jar file: " + reefJar); - } - ProcessStartInfo startInfo = new ProcessStartInfo() - { - FileName = GetJarBinary(), - Arguments = @"uf " + reefJar + " " + assembliesList, - RedirectStandardOutput = true, - RedirectStandardError = true, - UseShellExecute = false, - CreateNoWindow = true - }; - - LOGGER.Log(Level.Info, "updating jar file with \r\n" + startInfo.FileName + "\r\n" + startInfo.Arguments); - using (Process process = Process.Start(startInfo)) - { - StreamReader outReader = process.StandardOutput; - StreamReader errorReader = process.StandardError; - string output = outReader.ReadToEnd(); - string error = errorReader.ReadToEnd(); - process.WaitForExit(); - if (process.ExitCode != 0) - { - throw new InvalidOperationException("Failed to update jar file with stdout :" + output + - "and stderr:" + error); - } - } - LOGGER.Log(Level.Info, "jar file updated."); - } - } - - public static void ExtractConfigfileFromJar(string reefJar, IList<string> configFiles, string dropFolder) - { - var configFileNames = string.Join(" ", configFiles.ToArray()); - ProcessStartInfo startInfo = new ProcessStartInfo() - { - FileName = GetJarBinary(), - Arguments = @"xf " + reefJar + " " + configFileNames, - RedirectStandardOutput = true, - RedirectStandardError = true, - UseShellExecute = false, - CreateNoWindow = true - }; - - LOGGER.Log(Level.Info, "extracting files from jar file with \r\n" + startInfo.FileName + "\r\n" + startInfo.Arguments); - using (Process process = Process.Start(startInfo)) - { - StreamReader outReader = process.StandardOutput; - StreamReader errorReader = process.StandardError; - string output = outReader.ReadToEnd(); - string error = errorReader.ReadToEnd(); - process.WaitForExit(); - if (process.ExitCode != 0) - { - throw new InvalidOperationException("Failed to extract files from jar file with stdout :" + output + - "and stderr:" + error); - } - } - LOGGER.Log(Level.Info, "files are extracted."); - } - - private static string GetJarBinary() - { - string javaHome = Environment.GetEnvironmentVariable("JAVA_HOME"); - if (string.IsNullOrWhiteSpace(javaHome)) - { - LOGGER.Log(Level.Info, "JAVA_HOME not set. Please set JAVA_HOME environment variable first. Exiting..."); - Environment.Exit(1); - } - return Path.Combine(javaHome, "bin", "jar.exe"); - } - - private static string GetJavaBinary() - { - string javaHome = Environment.GetEnvironmentVariable("JAVA_HOME"); - if (string.IsNullOrWhiteSpace(javaHome)) - { - LOGGER.Log(Level.Info, "JAVA_HOME not set. Please set JAVA_HOME environment variable first. Exiting..."); - Environment.Exit(1); - } - return Path.Combine(javaHome, "bin", "java.exe"); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrHandlerHelper.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrHandlerHelper.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrHandlerHelper.cs deleted file mode 100644 index 78d3e0a..0000000 --- a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrHandlerHelper.cs +++ /dev/null @@ -1,177 +0,0 @@ -/** - * 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. - */ - -using Org.Apache.Reef.Utilities.Diagnostics; -using Org.Apache.Reef.Utilities.Logging; -using Org.Apache.Reef.Tang.Exceptions; -using Org.Apache.Reef.Tang.Formats; -using Org.Apache.Reef.Tang.Implementations; -using Org.Apache.Reef.Tang.Interface; -using Org.Apache.Reef.Tang.Protobuf; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices; - -namespace Org.Apache.Reef.Driver.Bridge -{ - public class ClrHandlerHelper - { - private static readonly Logger LOGGER = Logger.GetLogger(typeof(ClrHandlerHelper)); - - public static string[] ReefAssemblies - { - get - { - return new[] { "Microsoft.Hadoop.Avro.dll", "Org.Apache.Reef.Driver.dll", "Org.Apache.Reef.Common.dll", "Org.Apache.Reef.Utilities.dll", "Org.Apache.Reef.IO.Network.dll", "Org.Apache.Reef.Tang.dll", "Org.Apache.Reef.Wake.dll", "Newtonsoft.Json.dll", "protobuf-net.dll" }; - } - } - - internal static int MemoryGranularity { get; set; } - - public static ulong CreateHandler(object handler) - { - GCHandle gc = GCHandle.Alloc(handler); - IntPtr intPtr = GCHandle.ToIntPtr(gc); - ulong ul = (ulong)intPtr.ToInt64(); - return ul; - } - - public static void FreeHandle(ulong handle) - { - GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle); - gc.Free(); - } - - public static void SetMemoryGranuality(int granularity) - { - if (granularity <= 0) - { - var e = new ArgumentException("granularity must be a positive value, provided: " + granularity); - Exceptions.Throw(e, LOGGER); - } - MemoryGranularity = granularity; - } - - public static ulong CreateNullHandler() - { - return Constants.NullHandler; - } - - public static ISet<string> GetCommandLineArguments() - { - using (LOGGER.LogFunction("ClrHandlerHelper::GetCommandLineArguments")) - { - string bridgeConfiguration = Path.Combine(Directory.GetCurrentDirectory(), "reef", "global", - Constants.DriverBridgeConfiguration); - - if (!File.Exists(bridgeConfiguration)) - { - string error = "Configuraiton file not found: " + bridgeConfiguration; - LOGGER.Log(Level.Error, error); - Exceptions.Throw(new InvalidOperationException(error), LOGGER); - } - CommandLineArguments arguments; - IInjector injector; - try - { - IConfiguration driverBridgeConfiguration = - new AvroConfigurationSerializer().FromFile(bridgeConfiguration); - injector = TangFactory.GetTang().NewInjector(driverBridgeConfiguration); - arguments = injector.GetInstance<CommandLineArguments>(); - } - catch (InjectionException e) - { - string error = "Cannot inject command line arguments from driver bridge configuration. "; - Exceptions.Caught(e, Level.Error, error, LOGGER); - // return empty string set - return new HashSet<string>(); - } - return arguments.Arguments; - } - } - - public static void SupplyAdditionalClassPath(params string[] classPaths) - { - string path = Path.Combine(Directory.GetCurrentDirectory(), Constants.GlobalUserSuppliedJavaLibraries); - File.Delete(path); - File.WriteAllText(path, string.Join(",", classPaths)); - } - - public static void GenerateClassHierarchy(HashSet<string> clrDlls) - { - using (LOGGER.LogFunction("ClrHandlerHelper::GenerateClassHierarchy")) - { - IClassHierarchy ns = TangFactory.GetTang().GetClassHierarchy(clrDlls.ToArray()); - ProtocolBufferClassHierarchy.Serialize(Constants.ClassHierarachyBin, ns); - - LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Class hierarchy written to [{0}].", Path.Combine(Directory.GetCurrentDirectory(), Constants.ClassHierarachyBin))); - } - } - - public static string GetAssembliesListForReefDriverApp() - { - using (LOGGER.LogFunction("ClrHandlerHelper::GetAssembliesListForReefDriverApp")) - { - string executionDirectory = Directory.GetCurrentDirectory(); - IList<string> assemblies = - Directory.GetFiles(Path.Combine(executionDirectory, Constants.DriverAppDirectory), "*.dll") - .Select(f => string.Format(CultureInfo.InvariantCulture, "\"{0}\"", Constants.DriverAppDirectory + @"\" + Path.GetFileName(f))).ToList(); - - foreach (string reefAssembly in ReefAssemblies) - { - if (!File.Exists(reefAssembly)) - { - var e = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Assembly [{0}] needed for REEF driver not found in {1}", reefAssembly, executionDirectory)); - Exceptions.Throw(e, LOGGER); - } - File.Copy(reefAssembly, Path.Combine(executionDirectory, Constants.DriverAppDirectory, reefAssembly), overwrite: true); - assemblies.Add(string.Format(CultureInfo.InvariantCulture, "\"{0}\"", Constants.DriverAppDirectory + @"\" + reefAssembly)); - } - return string.Join(" ", assemblies); - } - } - - public static void CopyDllsToAppDirectory(HashSet<string> dlls) - { - using (LOGGER.LogFunction("ClrHandlerHelper::CopyDllsToAppDirectory")) - { - string executionDirectory = Directory.GetCurrentDirectory(); - Directory.CreateDirectory(Path.Combine(executionDirectory, Constants.DriverAppDirectory)); - foreach (string dll in dlls) - { - string dllFile = dll; - if (!dll.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) - { - dllFile += ".dll"; - } - if (!File.Exists(dllFile)) - { - var e = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Assembly [{0}] for REEF application not found in {1}", dllFile, executionDirectory)); - Exceptions.Throw(e, LOGGER); - } - File.Copy(dllFile, Path.Combine(executionDirectory, Constants.DriverAppDirectory, dllFile), overwrite: true); - } - } - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrSystemHandler.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrSystemHandler.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrSystemHandler.cs deleted file mode 100644 index 88fb410..0000000 --- a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrSystemHandler.cs +++ /dev/null @@ -1,53 +0,0 @@ -/** - * 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. - */ - -using System; -using System.Collections.Generic; - -namespace Org.Apache.Reef.Driver.Bridge -{ - public class ClrSystemHandler<T> : IObserver<T>, IObservable<T> - { - List<IObserver<T>> userHandlers = new List<IObserver<T>>(); - - public void OnNext(T value) - { - foreach (var observer in userHandlers) - { - observer.OnNext(value); - } - } - - public void OnError(Exception error) - { - throw new NotImplementedException(); - } - - public void OnCompleted() - { - throw new NotImplementedException(); - } - - public IDisposable Subscribe(IObserver<T> observer) - { - userHandlers.Add(observer); - return null; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrSystemHandlerWrapper.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrSystemHandlerWrapper.cs b/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrSystemHandlerWrapper.cs deleted file mode 100644 index bcd4be4..0000000 --- a/lang/cs/Source/REEF/reef-common/ReefDriver/bridge/ClrSystemHandlerWrapper.cs +++ /dev/null @@ -1,273 +0,0 @@ -/** - * 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. - */ - -using System; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using Org.Apache.Reef.Common.Context; -using Org.Apache.Reef.Driver.bridge; -using Org.Apache.Reef.Driver.Context; -using Org.Apache.Reef.Driver.Evaluator; -using Org.Apache.Reef.Driver.Task; -using Org.Apache.Reef.Utilities.Diagnostics; -using Org.Apache.Reef.Utilities.Logging; -using Org.Apache.Reef.Tang.Formats; -using Org.Apache.Reef.Tang.Implementations; -using Org.Apache.Reef.Tang.Interface; -using Org.Apache.Reef.Wake.Time; - -namespace Org.Apache.Reef.Driver.Bridge -{ - public class ClrSystemHandlerWrapper - { - private static readonly Logger LOGGER = Logger.GetLogger(typeof(ClrSystemHandlerWrapper)); - - private static DriverBridge _driverBridge; - - public static void Call_ClrSystemAllocatedEvaluatorHandler_OnNext(ulong handle, IAllocatedEvaluaotrClr2Java clr2Java) - { - using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemAllocatedEvaluatorHandler_OnNext")) - { - GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle); - ClrSystemHandler<IAllocatedEvaluator> obj = (ClrSystemHandler<IAllocatedEvaluator>)gc.Target; - obj.OnNext(new AllocatedEvaluator(clr2Java)); - } - } - - public static void Call_ClrSystemActiveContextHandler_OnNext(ulong handle, IActiveContextClr2Java clr2Java) - { - using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemActiveContextHandler_OnNext")) - { - GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle); - ClrSystemHandler<IActiveContext> obj = (ClrSystemHandler<IActiveContext>)gc.Target; - obj.OnNext(new ActiveContext(clr2Java)); - } - } - - public static void Call_ClrSystemDriverRestartActiveContextHandler_OnNext(ulong handle, IActiveContextClr2Java clr2Java) - { - using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemDriverRestartActiveContextHandler_OnNext")) - { - GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle); - ClrSystemHandler<IActiveContext> obj = (ClrSystemHandler<IActiveContext>)gc.Target; - obj.OnNext(new ActiveContext(clr2Java)); - } - } - - public static void Call_ClrSystemEvaluatorRequestor_OnNext(ulong handle, IEvaluatorRequestorClr2Java clr2Java) - { - using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemEvaluatorRequestor_OnNext")) - { - GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle); - ClrSystemHandler<IEvaluatorRequestor> obj = (ClrSystemHandler<IEvaluatorRequestor>)gc.Target; - obj.OnNext(new EvaluatorRequestor(clr2Java)); - } - } - - public static void Call_ClrSystemTaskMessage_OnNext(ulong handle, ITaskMessageClr2Java clr2Java, byte[] message) - { - using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemTaskMessage_OnNext")) - { - GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle); - ClrSystemHandler<ITaskMessage> obj = (ClrSystemHandler<ITaskMessage>)gc.Target; - obj.OnNext(new TaskMessage(clr2Java, message)); - } - } - - public static void Call_ClrSystemFailedTask_OnNext(ulong handle, IFailedTaskClr2Java clr2Java) - { - using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemFailedTask_OnNext")) - { - GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle); - ClrSystemHandler<IFailedTask> obj = (ClrSystemHandler<IFailedTask>)gc.Target; - obj.OnNext(new FailedTask(clr2Java)); - } - } - - public static void Call_ClrSystemRunningTask_OnNext(ulong handle, IRunningTaskClr2Java clr2Java) - { - using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemRunningTask_OnNext")) - { - GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle); - ClrSystemHandler<IRunningTask> obj = (ClrSystemHandler<IRunningTask>)gc.Target; - obj.OnNext(new RunningTask(clr2Java)); - } - } - - public static void Call_ClrSystemDriverRestartRunningTask_OnNext(ulong handle, IRunningTaskClr2Java clr2Java) - { - using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemDriverRestartRunningTask_OnNext")) - { - GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle); - ClrSystemHandler<IRunningTask> obj = (ClrSystemHandler<IRunningTask>)gc.Target; - obj.OnNext(new RunningTask(clr2Java)); - } - } - - public static void Call_ClrSystemFailedEvaluator_OnNext(ulong handle, IFailedEvaluatorClr2Java clr2Java) - { - using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemFailedEvaluator_OnNext")) - { - GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle); - ClrSystemHandler<IFailedEvaluator> obj = (ClrSystemHandler<IFailedEvaluator>)gc.Target; - obj.OnNext(new FailedEvaluator(clr2Java)); - } - } - - public static void Call_ClrSystemCompletedTask_OnNext(ulong handle, ICompletedTaskClr2Java clr2Java) - { - using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemCompletedTask_OnNext")) - { - GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle); - ClrSystemHandler<ICompletedTask> obj = (ClrSystemHandler<ICompletedTask>)gc.Target; - obj.OnNext(new CompletedTask(clr2Java)); - } - } - - public static void Call_ClrSystemSuspendedTask_OnNext(ulong handle, ISuspendedTaskClr2Java clr2Java) - { - using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemSuspendedTask_OnNext")) - { - GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle); - ClrSystemHandler<ISuspendedTask> obj = (ClrSystemHandler<ISuspendedTask>)gc.Target; - obj.OnNext(new SuspendedTask(clr2Java)); - } - } - - public static void Call_ClrSystemCompletedEvaluator_OnNext(ulong handle, ICompletedEvaluatorClr2Java clr2Java) - { - using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemCompletedEvaluator_OnNext")) - { - GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle); - ClrSystemHandler<ICompletedEvaluator> obj = (ClrSystemHandler<ICompletedEvaluator>)gc.Target; - obj.OnNext(new CompletedEvaluator(clr2Java)); - } - } - - public static void Call_ClrSystemHttpServer_OnNext(ulong handle, IHttpServerBridgeClr2Java clr2Java) - { - using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemHttpServer_OnNext")) - { - GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle); - ClrSystemHandler<IHttpMessage> obj = (ClrSystemHandler<IHttpMessage>)gc.Target; - obj.OnNext(new HttpMessage(clr2Java)); - } - } - - public static void Call_ClrSystemClosedContext_OnNext(ulong handle, IClosedContextClr2Java clr2Java) - { - using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemClosedContext_OnNext")) - { - GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle); - ClrSystemHandler<IClosedContext> obj = (ClrSystemHandler<IClosedContext>)gc.Target; - obj.OnNext(new ClosedContext(clr2Java)); - } - } - - public static void Call_ClrSystemFailedContext_OnNext(ulong handle, IFailedContextClr2Java clr2Java) - { - using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemFailedContext_OnNext")) - { - GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle); - ClrSystemHandler<IFailedContext> obj = (ClrSystemHandler<IFailedContext>)gc.Target; - obj.OnNext(new FailedContext(clr2Java)); - } - } - - public static void Call_ClrSystemContextMessage_OnNext(ulong handle, IContextMessageClr2Java clr2Java) - { - using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemContextMessage_OnNext")) - { - GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle); - ClrSystemHandler<IContextMessage> obj = (ClrSystemHandler<IContextMessage>)gc.Target; - obj.OnNext(new ContextMessage(clr2Java)); - } - } - - public static void Call_ClrSystemDriverRestart_OnNext(ulong handle) - { - using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemDriverRestart_OnNext")) - { - GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle); - ClrSystemHandler<StartTime> obj = (ClrSystemHandler<StartTime>)gc.Target; - obj.OnNext(new StartTime(DateTime.Now.Ticks)); - } - } - - //Deprecate, remove after both Java and C# code gets checked in - public static ulong[] Call_ClrSystemStartHandler_OnStart(DateTime startTime) - { - using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemStartHandler_OnStart")) - { - LOGGER.Log(Level.Info, "*** Start time is " + startTime); - return GetHandlers(null); - } - } - - public static ulong[] Call_ClrSystemStartHandler_OnStart(DateTime startTime, string httpServerPort) - { - using (LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemStartHandler_OnStart")) - { - LOGGER.Log(Level.Info, "*** Start time is " + startTime); - LOGGER.Log(Level.Info, "*** httpServerPort: " + httpServerPort); - return GetHandlers(httpServerPort); - } - } - - private static ulong[] GetHandlers(string httpServerPortNumber) - { - IStartHandler startHandler; - IInjector injector = null; - string errorMessage; - string bridgeConfiguration = Path.Combine(Directory.GetCurrentDirectory(), "reef", "global", Constants.DriverBridgeConfiguration); - if (!File.Exists(bridgeConfiguration)) - { - errorMessage = "Cannot find CLR Driver bridge configuration file " + bridgeConfiguration; - Exceptions.Throw(new InvalidOperationException(errorMessage), LOGGER); - } - try - { - IConfiguration driverBridgeConfiguration = new AvroConfigurationSerializer().FromFile(bridgeConfiguration); - injector = TangFactory.GetTang().NewInjector(driverBridgeConfiguration); - } - catch (Exception e) - { - errorMessage = "Failed to get injector from driver bridge configuration."; - Exceptions.CaughtAndThrow(new InvalidOperationException(errorMessage, e), Level.Error, errorMessage, LOGGER); - } - - try - { - HttpServerPort port = injector.GetInstance<HttpServerPort>(); - port.PortNumber = httpServerPortNumber == null ? 0 : int.Parse(httpServerPortNumber, CultureInfo.InvariantCulture); - - startHandler = injector.GetInstance<IStartHandler>(); - LOGGER.Log(Level.Info, "Start handler set to be " + startHandler.Identifier); - _driverBridge = injector.GetInstance<DriverBridge>(); - } - catch (Exception e) - { - Exceptions.CaughtAndThrow(e, Level.Error, "Cannot get instance.", LOGGER); - } - - return _driverBridge.Subscribe(); - } - } -} \ No newline at end of file
