http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Common/tasks/IRunningTask.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Common/tasks/IRunningTask.cs b/lang/cs/Org.Apache.REEF.Common/tasks/IRunningTask.cs deleted file mode 100644 index 1e76d1d..0000000 --- a/lang/cs/Org.Apache.REEF.Common/tasks/IRunningTask.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 Org.Apache.REEF.Utilities; -using System; - -namespace Org.Apache.REEF.Common.Task -{ - /// <summary> - /// Represents a running Task - /// </summary> - public interface IRunningTask : IIdentifiable, IDisposable - { - /// <summary> - /// Sends the message to the running task. - /// </summary> - /// <param name="message"></param> - void OnNext(byte[] message); - - /// <summary> - /// Signal the task to suspend. - /// </summary> - /// <param name="message">a message that is sent to the Task.</param> - void Suspend(byte[] message); - - /// <summary> - /// Sends the message to the running task. - /// </summary> - void Suspend(); - - /// <summary> - /// Signal the task to shut down. - /// </summary> - /// <param name="message">a message that is sent to the Task.</param> - void Dispose(byte[] message); - } -}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Common/tasks/ITask.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Common/tasks/ITask.cs b/lang/cs/Org.Apache.REEF.Common/tasks/ITask.cs deleted file mode 100644 index 42cc10e..0000000 --- a/lang/cs/Org.Apache.REEF.Common/tasks/ITask.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. - */ - -using System; - -namespace Org.Apache.REEF.Tasks -{ - public interface ITask : IDisposable - { - byte[] Call(byte[] memento); - } -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Common/tasks/ITaskMessageSource.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Common/tasks/ITaskMessageSource.cs b/lang/cs/Org.Apache.REEF.Common/tasks/ITaskMessageSource.cs deleted file mode 100644 index 141ba89..0000000 --- a/lang/cs/Org.Apache.REEF.Common/tasks/ITaskMessageSource.cs +++ /dev/null @@ -1,31 +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.Tasks.Defaults; -using Org.Apache.REEF.Utilities; -using Org.Apache.REEF.Tang.Annotations; - -namespace Org.Apache.REEF.Tasks -{ - [DefaultImplementation(typeof(DefaultTaskMessageSource))] - public interface ITaskMessageSource - { - Optional<TaskMessage> Message { get; set; } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Common/tasks/TaskConfiguration.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Common/tasks/TaskConfiguration.cs b/lang/cs/Org.Apache.REEF.Common/tasks/TaskConfiguration.cs deleted file mode 100644 index cd82d2a..0000000 --- a/lang/cs/Org.Apache.REEF.Common/tasks/TaskConfiguration.cs +++ /dev/null @@ -1,148 +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.Tasks.Events; -using Org.Apache.REEF.Utilities.Logging; -using Org.Apache.REEF.Tang.Formats; -using Org.Apache.REEF.Tang.Interface; -using Org.Apache.REEF.Tang.Util; -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; - -[module: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "static readonly field, typical usage in configurations")] - -namespace Org.Apache.REEF.Tasks -{ - public class TaskConfiguration : ConfigurationModuleBuilder - { - // this is a hack for getting the task identifier for now - public const string TaskIdentifier = "TaskConfigurationOptions+Identifier"; - - /// <summary> - /// The identifier of the task. - /// </summary> - [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")] - public static readonly RequiredParameter<string> Identifier = new RequiredParameter<string>(); - - /// <summary> - /// The task to instantiate. - /// </summary> - [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")] - public static readonly RequiredImpl<ITask> Task = new RequiredImpl<ITask>(); - - /// <summary> - /// for task suspension. Defaults to task failure if not bound. - /// </summary> - [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")] - public static readonly OptionalImpl<IObserver<ISuspendEvent>> OnSuspend = new OptionalImpl<IObserver<ISuspendEvent>>(); - - /// <summary> - /// for messages from the driver. Defaults to task failure if not bound. - /// </summary> - [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")] - public static readonly OptionalImpl<IDriverMessageHandler> OnMessage = new OptionalImpl<IDriverMessageHandler>(); - - /// <summary> - /// for closure requests from the driver. Defaults to task failure if not bound. - /// </summary> - [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")] - public static readonly OptionalImpl<IObserver<ICloseEvent>> OnClose = new OptionalImpl<IObserver<ICloseEvent>>(); - - /// <summary> - /// Message source invoked upon each evaluator heartbeat. - /// </summary> - [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")] - public static readonly OptionalImpl<ITaskMessageSource> OnSendMessage = new OptionalImpl<ITaskMessageSource>(); - - /// <summary> - /// to receive TaskStart after the Task.call() method was called. - /// </summary> - [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")] - public static readonly OptionalImpl<IObserver<ITaskStart>> OnTaskStart = new OptionalImpl<IObserver<ITaskStart>>(); - - /// <summary> - /// to receive TaskStop after the Task.call() method returned. - /// </summary> - [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")] - public static readonly OptionalImpl<IObserver<ITaskStop>> OnTaskStop = new OptionalImpl<IObserver<ITaskStop>>(); - - /// <summary> - /// The memento to be passed to Task.call(). - /// </summary> - [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")] - public static readonly OptionalParameter<string> Memento = new OptionalParameter<string>(); - - private static readonly Logger LOGGER = Logger.GetLogger(typeof(TaskConfiguration)); - - public TaskConfiguration() - : base() - { - } - - public TaskConfiguration(string configString) - { - TangConfig = new AvroConfigurationSerializer().FromString(configString); - AvroConfiguration avroConfiguration = AvroConfiguration.GetAvroConfigurationFromEmbeddedString(configString); - foreach (ConfigurationEntry config in avroConfiguration.Bindings) - { - if (config.key.Contains(TaskIdentifier)) - { - TaskId = config.value; - } - } - if (string.IsNullOrWhiteSpace(TaskId)) - { - string msg = "Required parameter TaskId not provided."; - LOGGER.Log(Level.Error, msg); - Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException(msg), LOGGER); - } - } - - public static ConfigurationModule ConfigurationModule - { - get - { - return new TaskConfiguration() - .BindImplementation(GenericType<ITask>.Class, Task) - .BindImplementation(GenericType<ITaskMessageSource>.Class, OnSendMessage) - .BindImplementation(GenericType<IDriverMessageHandler>.Class, OnMessage) - .BindNamedParameter(GenericType<TaskConfigurationOptions.Identifier>.Class, Identifier) - .BindNamedParameter(GenericType<TaskConfigurationOptions.Memento>.Class, Memento) - .BindNamedParameter(GenericType<TaskConfigurationOptions.CloseHandler>.Class, OnClose) - .BindNamedParameter(GenericType<TaskConfigurationOptions.SuspendHandler>.Class, OnSuspend) - .BindSetEntry(GenericType<TaskConfigurationOptions.StartHandlers>.Class, OnTaskStart) - .BindSetEntry(GenericType<TaskConfigurationOptions.StopHandlers>.Class, OnTaskStop) - .Build(); - } - } - - public string TaskId { get; private set; } - - public IList<KeyValuePair<string, string>> Configurations { get; private set; } - - public IConfiguration TangConfig { get; private set; } - - public override string ToString() - { - return string.Format(CultureInfo.InvariantCulture, "TaskConfiguration - configurations: {0}", TangConfig.ToString()); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Common/tasks/TaskConfigurationOptions.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Common/tasks/TaskConfigurationOptions.cs b/lang/cs/Org.Apache.REEF.Common/tasks/TaskConfigurationOptions.cs deleted file mode 100644 index db50d78..0000000 --- a/lang/cs/Org.Apache.REEF.Common/tasks/TaskConfigurationOptions.cs +++ /dev/null @@ -1,69 +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.Tasks.Events; -using Org.Apache.REEF.Tang.Annotations; -using System; -using System.Collections.Generic; - -namespace Org.Apache.REEF.Tasks -{ - public class TaskConfigurationOptions - { - [NamedParameter("The Identifier of the Task", "taskid", "Task")] - public class Identifier : Name<string> - { - } - - [NamedParameter(documentation: "The memento to be used for the Task")] - public class Memento : Name<string> - { - } - - [NamedParameter("TaskMessageSource", "messagesource", null)] - public class TaskMessageSources : Name<ISet<ITaskMessageSource>> - { - } - - [NamedParameter(documentation: "The set of event handlers for the TaskStart event.")] - public class StartHandlers : Name<ISet<IObserver<ITaskStart>>> - { - } - - [NamedParameter(documentation: "The set of event handlers for the TaskStop event.")] - public class StopHandlers : Name<ISet<IObserver<ITaskStop>>> - { - } - - [NamedParameter(documentation: "The event handler that receives the close event.")] - public class CloseHandler : Name<IObserver<ICloseEvent>> - { - } - - [NamedParameter(documentation: "The event handler that receives the suspend event.")] - public class SuspendHandler : Name<IObserver<ISuspendEvent>> - { - } - - [NamedParameter(documentation: "The event handler that receives messages from the driver.")] - public class MessageHandler : Name<IObserver<IDriverMessage>> - { - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Common/tasks/TaskMessage.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Common/tasks/TaskMessage.cs b/lang/cs/Org.Apache.REEF.Common/tasks/TaskMessage.cs deleted file mode 100644 index bc96016..0000000 --- a/lang/cs/Org.Apache.REEF.Common/tasks/TaskMessage.cs +++ /dev/null @@ -1,68 +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; -using System; -using Org.Apache.REEF.Utilities.Logging; - -namespace Org.Apache.REEF.Tasks -{ - public class TaskMessage : IMessage - { - private static readonly Logger LOGGER = Logger.GetLogger(typeof(TaskMessage)); - private readonly string _messageSourcId; - private readonly byte[] _bytes; - - private TaskMessage(string messageSourceId, byte[] bytes) - { - _messageSourcId = messageSourceId; - _bytes = bytes; - } - - public string MessageSourceId - { - get { return _messageSourcId; } - } - - public byte[] Message - { - get { return _bytes; } - set { } - } - - /// <summary> - /// From byte[] message to a TaskMessage - /// </summary> - /// <param name="messageSourceId">messageSourceId The message's sourceID. This will be accessible in the Driver for routing</param> - /// <param name="message">The actual content of the message, serialized into a byte[]</param> - /// <returns>a new TaskMessage with the given content</returns> - public static TaskMessage From(string messageSourceId, byte[] message) - { - if (string.IsNullOrEmpty(messageSourceId)) - { - Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(new ArgumentNullException("messageSourceId"), LOGGER); - } - if (message == null) - { - Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(new ArgumentNullException("bytes"), LOGGER); - } - return new TaskMessage(messageSourceId, message); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Common/tasks/defaults/DefaultDriverMessageHandler.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Common/tasks/defaults/DefaultDriverMessageHandler.cs b/lang/cs/Org.Apache.REEF.Common/tasks/defaults/DefaultDriverMessageHandler.cs deleted file mode 100644 index 3749f2b..0000000 --- a/lang/cs/Org.Apache.REEF.Common/tasks/defaults/DefaultDriverMessageHandler.cs +++ /dev/null @@ -1,42 +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.Tasks.Events; -using Org.Apache.REEF.Utilities.Diagnostics; -using Org.Apache.REEF.Utilities.Logging; -using Org.Apache.REEF.Tang.Annotations; -using System; - -namespace Org.Apache.REEF.Tasks.Defaults -{ - public class DefaultDriverMessageHandler : IDriverMessageHandler - { - private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultDriverMessageHandler)); - - [Inject] - public DefaultDriverMessageHandler() - { - } - - public void Handle(IDriverMessage message) - { - Exceptions.Throw(new InvalidOperationException("No DriverMessage handler bound. Message received" + message), LOGGER); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Common/tasks/defaults/DefaultTaskMessageSource.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Common/tasks/defaults/DefaultTaskMessageSource.cs b/lang/cs/Org.Apache.REEF.Common/tasks/defaults/DefaultTaskMessageSource.cs deleted file mode 100644 index 4549ab5..0000000 --- a/lang/cs/Org.Apache.REEF.Common/tasks/defaults/DefaultTaskMessageSource.cs +++ /dev/null @@ -1,49 +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; -using Org.Apache.REEF.Tang.Annotations; -using System; -using System.Globalization; - -namespace Org.Apache.REEF.Tasks.Defaults -{ - public class DefaultTaskMessageSource : ITaskMessageSource - { - [Inject] - public DefaultTaskMessageSource() - { - } - - public Optional<TaskMessage> Message - { - get - { - TaskMessage defaultTaskMessage = TaskMessage.From( - "defaultSourceId", - ByteUtilities.StringToByteArrays("default message generated at " + DateTime.Now.ToString(CultureInfo.InvariantCulture))); - return Optional<TaskMessage>.Of(defaultTaskMessage); - } - - set - { - } - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Common/tasks/events/ICloseEvent.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Common/tasks/events/ICloseEvent.cs b/lang/cs/Org.Apache.REEF.Common/tasks/events/ICloseEvent.cs deleted file mode 100644 index e9737c3..0000000 --- a/lang/cs/Org.Apache.REEF.Common/tasks/events/ICloseEvent.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. - */ - -using Org.Apache.REEF.Utilities; - -namespace Org.Apache.REEF.Tasks.Events -{ - public interface ICloseEvent - { - Optional<byte[]> Value { get; set; } - } -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Common/tasks/events/IDriverMessage.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Common/tasks/events/IDriverMessage.cs b/lang/cs/Org.Apache.REEF.Common/tasks/events/IDriverMessage.cs deleted file mode 100644 index a1ead6d..0000000 --- a/lang/cs/Org.Apache.REEF.Common/tasks/events/IDriverMessage.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. - */ - -using Org.Apache.REEF.Utilities; - -namespace Org.Apache.REEF.Tasks.Events -{ - public interface IDriverMessage - { - Optional<byte[]> Message { get; } - } -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Common/tasks/events/ISuspendEvent.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Common/tasks/events/ISuspendEvent.cs b/lang/cs/Org.Apache.REEF.Common/tasks/events/ISuspendEvent.cs deleted file mode 100644 index 1926c75..0000000 --- a/lang/cs/Org.Apache.REEF.Common/tasks/events/ISuspendEvent.cs +++ /dev/null @@ -1,25 +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.Tasks.Events -{ - public interface ISuspendEvent - { - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Common/tasks/events/ITaskStart.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Common/tasks/events/ITaskStart.cs b/lang/cs/Org.Apache.REEF.Common/tasks/events/ITaskStart.cs deleted file mode 100644 index 7b15609..0000000 --- a/lang/cs/Org.Apache.REEF.Common/tasks/events/ITaskStart.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.Tasks.Events -{ - public interface ITaskStart - { - string Id { get; set; } - } -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Common/tasks/events/ITaskStop.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Common/tasks/events/ITaskStop.cs b/lang/cs/Org.Apache.REEF.Common/tasks/events/ITaskStop.cs deleted file mode 100644 index 62e9254..0000000 --- a/lang/cs/Org.Apache.REEF.Common/tasks/events/ITaskStop.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.Tasks.Events -{ - public interface ITaskStop - { - string Id { get; } - } -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Bridge/BridgeLogger.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/BridgeLogger.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/BridgeLogger.cs new file mode 100644 index 0000000..3e2dada --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/BridgeLogger.cs @@ -0,0 +1,65 @@ +/** + * 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/7edb8570/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IActiveContextClr2Java.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IActiveContextClr2Java.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IActiveContextClr2Java.cs new file mode 100644 index 0000000..6ef03f9 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IActiveContextClr2Java.cs @@ -0,0 +1,36 @@ +/** + * 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.Driver.Evaluator; + +namespace Org.Apache.REEF.Driver.Bridge.Clr2java +{ + public interface IActiveContextClr2Java : IClr2Java + { + void SubmitTask(string taskConfigStr); + + void Close(); + + string GetId(); + + string GetEvaluatorId(); + + IEvaluatorDescriptor GetEvaluatorDescriptor(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IAllocatedEvaluaotrClr2Java.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IAllocatedEvaluaotrClr2Java.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IAllocatedEvaluaotrClr2Java.cs new file mode 100644 index 0000000..0e24bc3 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IAllocatedEvaluaotrClr2Java.cs @@ -0,0 +1,42 @@ +/** + * 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.Driver.Evaluator; + +namespace Org.Apache.REEF.Driver.Bridge.Clr2java +{ + public interface IAllocatedEvaluaotrClr2Java : IClr2Java + { + void SubmitContextAndTask(string contextConfigStr, string taskConfigStr); + + void SubmitContext(string contextConfigStr); + + void SubmitContextAndService(string contextConfigStr, string serviceConfigStr); + + void SubmitContextAndServiceAndTask(string contextConfigStr, string serviceConfigStr, string taskConfigStr); + + void Close(); + + string GetId(); + + string GetNameServerInfo(); + + IEvaluatorDescriptor GetEvaluatorDescriptor(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IClosedContextClr2Java.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IClosedContextClr2Java.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IClosedContextClr2Java.cs new file mode 100644 index 0000000..7677a41 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IClosedContextClr2Java.cs @@ -0,0 +1,34 @@ +/** + * 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.Driver.Evaluator; + +namespace Org.Apache.REEF.Driver.Bridge.Clr2java +{ + public interface IClosedContextClr2Java : IClr2Java + { + string GetId(); + + string GetEvaluatorId(); + + IEvaluatorDescriptor GetEvaluatorDescriptor(); + + IActiveContextClr2Java GetParentContext(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IClr2Java.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IClr2Java.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IClr2Java.cs new file mode 100644 index 0000000..b6c9154 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IClr2Java.cs @@ -0,0 +1,26 @@ +/** + * 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.Bridge.Clr2java +{ + public interface IClr2Java + { + void OnError(string message); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/ICompletedEvaluatorClr2Java.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/ICompletedEvaluatorClr2Java.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/ICompletedEvaluatorClr2Java.cs new file mode 100644 index 0000000..99e37d7 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/ICompletedEvaluatorClr2Java.cs @@ -0,0 +1,30 @@ +/** + * 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.Bridge.Clr2java +{ + public interface ICompletedEvaluatorClr2Java : IClr2Java + { + /// <summary> + /// evaluator id + /// </summary> + /// <returns>id of the completed evaluator</returns> + string GetId(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/ICompletedTaskClr2Java.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/ICompletedTaskClr2Java.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/ICompletedTaskClr2Java.cs new file mode 100644 index 0000000..5eb2686 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/ICompletedTaskClr2Java.cs @@ -0,0 +1,28 @@ +/** + * 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.Bridge.Clr2java +{ + public interface ICompletedTaskClr2Java : IClr2Java + { + IActiveContextClr2Java GetActiveContext(); + + string GetId(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IContextMessageClr2Java.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IContextMessageClr2Java.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IContextMessageClr2Java.cs new file mode 100644 index 0000000..9af42b7 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IContextMessageClr2Java.cs @@ -0,0 +1,30 @@ +/** + * 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.Bridge.Clr2java +{ + public interface IContextMessageClr2Java : IClr2Java + { + byte[] Get(); + + string GetId(); + + string GetMessageSourceId(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IEvaluatorRequestorClr2Java.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IEvaluatorRequestorClr2Java.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IEvaluatorRequestorClr2Java.cs new file mode 100644 index 0000000..940ed43 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IEvaluatorRequestorClr2Java.cs @@ -0,0 +1,28 @@ +/** + * 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.Driver.Evaluator; + +namespace Org.Apache.REEF.Driver.Bridge.Clr2java +{ + public interface IEvaluatorRequestorClr2Java : IClr2Java + { + void Submit(IEvaluatorRequest evaluatorRequest); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IFailedContextClr2Java.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IFailedContextClr2Java.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IFailedContextClr2Java.cs new file mode 100644 index 0000000..1b22645 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IFailedContextClr2Java.cs @@ -0,0 +1,36 @@ +/** + * 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.Driver.Evaluator; + +namespace Org.Apache.REEF.Driver.Bridge.Clr2java +{ + public interface IFailedContextClr2Java : IClr2Java + { + string GetId(); + + string GetEvaluatorId(); + + string GetParentId(); + + IEvaluatorDescriptor GetEvaluatorDescriptor(); + + IActiveContextClr2Java GetParentContext(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IFailedEvaluatorClr2Java.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IFailedEvaluatorClr2Java.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IFailedEvaluatorClr2Java.cs new file mode 100644 index 0000000..12b007d --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IFailedEvaluatorClr2Java.cs @@ -0,0 +1,28 @@ +/** + * 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.Bridge.Clr2java +{ + public interface IFailedEvaluatorClr2Java + { + IEvaluatorRequestorClr2Java GetEvaluatorRequestor(); + + string GetId(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IFailedTaskClr2Java.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IFailedTaskClr2Java.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IFailedTaskClr2Java.cs new file mode 100644 index 0000000..384502e --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IFailedTaskClr2Java.cs @@ -0,0 +1,28 @@ +/** + * 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.Bridge.Clr2java +{ + public interface IFailedTaskClr2Java : IClr2Java + { + IActiveContextClr2Java GetActiveContext(); + + string GetString(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IHttpServerBridgeClr2Java.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IHttpServerBridgeClr2Java.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IHttpServerBridgeClr2Java.cs new file mode 100644 index 0000000..3b13aed --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IHttpServerBridgeClr2Java.cs @@ -0,0 +1,34 @@ +/** + * 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.Bridge.Clr2java +{ + public interface IHttpServerBridgeClr2Java : IClr2Java + { + string GetQueryString(); + + void SetQueryResult(string queryResult); + + byte[] GetQueryRequestData(); + + void SetQueryResponseData(byte[] responseData); + + void SetUriSpecification(string uriSpecification); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IRunningTaskClr2Java.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IRunningTaskClr2Java.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IRunningTaskClr2Java.cs new file mode 100644 index 0000000..e807e04 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/IRunningTaskClr2Java.cs @@ -0,0 +1,30 @@ +/** + * 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.Bridge.Clr2java +{ + public interface IRunningTaskClr2Java : IClr2Java + { + IActiveContextClr2Java GetActiveContext(); + + string GetId(); + + void Send(byte[] message); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/ISuspendedTaskClr2Java.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/ISuspendedTaskClr2Java.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/ISuspendedTaskClr2Java.cs new file mode 100644 index 0000000..95bfa8b --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/ISuspendedTaskClr2Java.cs @@ -0,0 +1,42 @@ +/** + * 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.Bridge.Clr2java +{ + public interface ISuspendedTaskClr2Java : IClr2Java + { + /// <summary> + /// get active context the task is running in + /// </summary> + /// <returns>active context</returns> + IActiveContextClr2Java GetActiveContext(); + + /// <summary> + /// get suspsended task id + /// </summary> + /// <returns>suspsended task id</returns> + string GetId(); + + /// <summary> + /// get the message + /// </summary> + /// <returns>suspended task message</returns> + byte[] Get(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/ITaskMessageClr2Java.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/ITaskMessageClr2Java.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/ITaskMessageClr2Java.cs new file mode 100644 index 0000000..3e3abb3 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/Clr2java/ITaskMessageClr2Java.cs @@ -0,0 +1,26 @@ +/** + * 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.Bridge.Clr2java +{ + public interface ITaskMessageClr2Java : IClr2Java + { + string GetId(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Bridge/ClrClientHelper.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/ClrClientHelper.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/ClrClientHelper.cs new file mode 100644 index 0000000..8ccade9 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/ClrClientHelper.cs @@ -0,0 +1,174 @@ +/** + * 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.Tang.Formats; +using Org.Apache.REEF.Tang.Interface; +using Org.Apache.REEF.Utilities.Logging; + +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/7edb8570/lang/cs/Org.Apache.REEF.Driver/Bridge/ClrHandlerHelper.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/ClrHandlerHelper.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/ClrHandlerHelper.cs new file mode 100644 index 0000000..8d9020c --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/ClrHandlerHelper.cs @@ -0,0 +1,178 @@ +/** + * 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; +using Org.Apache.REEF.Tang.Implementations.Tang; + +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.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/7edb8570/lang/cs/Org.Apache.REEF.Driver/Bridge/ClrSystemHandler.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/ClrSystemHandler.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/ClrSystemHandler.cs new file mode 100644 index 0000000..15b957d --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/ClrSystemHandler.cs @@ -0,0 +1,53 @@ +/** + * 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; + } + } +}
