http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultEvaluatorAllocationHandler.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultEvaluatorAllocationHandler.cs b/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultEvaluatorAllocationHandler.cs new file mode 100644 index 0000000..9216b64 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultEvaluatorAllocationHandler.cs @@ -0,0 +1,57 @@ +/** + * 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.Evaluator; +using Org.Apache.REEF.Driver.Evaluator; +using Org.Apache.REEF.Utilities.Logging; +using Org.Apache.REEF.Tang.Annotations; +using System; +using System.Globalization; + +namespace Org.Apache.REEF.Driver.Defaults +{ + /// <summary> + /// Default handler for AllocatedEvaluator: close it. + /// </summary> + public class DefaultEvaluatorAllocationHandler : IObserver<IAllocatedEvaluator> + { + private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultEvaluatorAllocationHandler)); + + [Inject] + public DefaultEvaluatorAllocationHandler() + { + } + + public void OnNext(IAllocatedEvaluator value) + { + LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Received AllocatedEvaluator : {0}, closing", value.Id)); + value.Dispose(); + } + + public void OnError(Exception error) + { + throw new NotImplementedException(); + } + + public void OnCompleted() + { + throw new NotImplementedException(); + } + } +}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultEvaluatorCompletionHandler.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultEvaluatorCompletionHandler.cs b/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultEvaluatorCompletionHandler.cs new file mode 100644 index 0000000..fcea53d --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultEvaluatorCompletionHandler.cs @@ -0,0 +1,54 @@ +/** + * 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; +using Org.Apache.REEF.Utilities.Logging; +using Org.Apache.REEF.Tang.Annotations; +using System; + +namespace Org.Apache.REEF.Driver.Defaults +{ + /// <summary> + /// Default event handler for CompletedEvaluator: Logging it. + /// </summary> + public class DefaultEvaluatorCompletionHandler : IObserver<ICompletedEvaluator> + { + private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultEvaluatorCompletionHandler)); + + [Inject] + public DefaultEvaluatorCompletionHandler() + { + } + + public void OnNext(ICompletedEvaluator value) + { + LOGGER.Log(Level.Info, "Received CompletedEvaluator: " + value.Id); + } + + public void OnError(Exception error) + { + throw new NotImplementedException(); + } + + public void OnCompleted() + { + throw new NotImplementedException(); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultEvaluatorFailureHandler.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultEvaluatorFailureHandler.cs b/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultEvaluatorFailureHandler.cs new file mode 100644 index 0000000..82cfd26 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultEvaluatorFailureHandler.cs @@ -0,0 +1,55 @@ +/** + * 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; +using Org.Apache.REEF.Utilities.Diagnostics; +using Org.Apache.REEF.Utilities.Logging; +using Org.Apache.REEF.Tang.Annotations; +using System; +using System.Globalization; + +namespace Org.Apache.REEF.Driver.Defaults +{ + /// <summary> + /// Default event handler used for FailedEvaluator: It crashes the driver. + /// </summary> + public class DefaultEvaluatorFailureHandler : IObserver<IFailedEvaluator> + { + [Inject] + public DefaultEvaluatorFailureHandler() + { + } + + public void OnNext(IFailedEvaluator value) + { + var e = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Evaluator {0} failed, and no handler is bound for FailedEvaluator.", value.Id)); + Exceptions.Throw(e, Logger.GetLogger(typeof(DefaultEvaluatorFailureHandler))); + } + + public void OnError(Exception error) + { + throw new NotImplementedException(); + } + + public void OnCompleted() + { + throw new NotImplementedException(); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultEvaluatorRequestorHandler.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultEvaluatorRequestorHandler.cs b/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultEvaluatorRequestorHandler.cs new file mode 100644 index 0000000..465baa7 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultEvaluatorRequestorHandler.cs @@ -0,0 +1,61 @@ +/** + * 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.Bridge; +using Org.Apache.REEF.Driver.Evaluator; +using Org.Apache.REEF.Utilities.Logging; +using Org.Apache.REEF.Tang.Annotations; +using System; + +namespace Org.Apache.REEF.Driver.Defaults +{ + /// <summary> + /// Default handler for close messages from the client: logging it + /// </summary> + public class DefaultEvaluatorRequestorHandler : IObserver<IEvaluatorRequestor> + { + private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultClientCloseHandler)); + + [Inject] + public DefaultEvaluatorRequestorHandler() + { + } + + public void OnNext(IEvaluatorRequestor value) + { + LOGGER.Log(Level.Info, "Default evaluator requstor: requesting 1 evaluator with 512 MB"); + int evaluatorsNumber = 1; + int memory = 512; + string rack = "WonderlandRack"; + EvaluatorRequest request = new EvaluatorRequest(evaluatorsNumber, memory, rack); + + value.Submit(request); + } + + public void OnError(Exception error) + { + throw new NotImplementedException(); + } + + public void OnCompleted() + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultHttpHandler.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultHttpHandler.cs b/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultHttpHandler.cs new file mode 100644 index 0000000..831eebe --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultHttpHandler.cs @@ -0,0 +1,49 @@ +/** + * 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.Net; +using Org.Apache.REEF.Driver.Bridge; +using Org.Apache.REEF.Utilities; +using Org.Apache.REEF.Utilities.Logging; +using Org.Apache.REEF.Tang.Annotations; + +namespace Org.Apache.REEF.Driver.Defaults +{ + public class DefaultHttpHandler : IHttpHandler + { + private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultHttpHandler)); + + [Inject] + public DefaultHttpHandler() + { + } + + public string GetSpecification() + { + return "Ping"; + } + + public void OnHttpRequest(ReefHttpRequest requet, ReefHttpResponse response) + { + LOGGER.Log(Level.Info, "OnHttpRequest in DefaultHttpHandler is called."); + response.Status = HttpStatusCode.OK; + response.OutputStream = ByteUtilities.StringToByteArrays("Byte array returned from DefaultHttpHandler in CLR!!!"); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultTaskCompletionHandler.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultTaskCompletionHandler.cs b/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultTaskCompletionHandler.cs new file mode 100644 index 0000000..53eb832 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultTaskCompletionHandler.cs @@ -0,0 +1,60 @@ +/** + * 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.Context; +using Org.Apache.REEF.Common.Tasks; +using Org.Apache.REEF.Driver.Context; +using Org.Apache.REEF.Driver.Task; +using Org.Apache.REEF.Utilities.Logging; +using Org.Apache.REEF.Tang.Annotations; +using System; +using System.Globalization; + +namespace Org.Apache.REEF.Driver.Defaults +{ + /// <summary> + /// efault event handler for CompletedTask: Log it and close the context. + /// </summary> + public class DefaultTaskCompletionHandler : IObserver<ICompletedTask> + { + private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultTaskCompletionHandler)); + + [Inject] + public DefaultTaskCompletionHandler() + { + } + + public void OnNext(ICompletedTask value) + { + IActiveContext activeContext = value.ActiveContext; + LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Received CompletedTask: {0} :: CLOSING context: {1}", value.Id, activeContext.Id)); + activeContext.Dispose(); + } + + public void OnError(Exception error) + { + throw new NotImplementedException(); + } + + public void OnCompleted() + { + throw new NotImplementedException(); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultTaskFailureHandler.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultTaskFailureHandler.cs b/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultTaskFailureHandler.cs new file mode 100644 index 0000000..7235a1b --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultTaskFailureHandler.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 Org.Apache.REEF.Common.Tasks; +using Org.Apache.REEF.Driver.Task; +using Org.Apache.REEF.Tang.Annotations; +using System; +using System.Globalization; + +namespace Org.Apache.REEF.Driver.Defaults +{ + /// <summary> + /// Default event handler used for FailedTask: It crashes the driver. + /// </summary> + public class DefaultTaskFailureHandler : IObserver<IFailedTask> + { + [Inject] + public DefaultTaskFailureHandler() + { + } + + public void OnNext(IFailedTask value) + { + throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Task {0} has failed, and no handler was bound for IFailedTask", value.Id) ); + } + + public void OnError(Exception error) + { + throw new NotImplementedException(); + } + + public void OnCompleted() + { + throw new NotImplementedException(); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultTaskMessageHandler.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultTaskMessageHandler.cs b/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultTaskMessageHandler.cs new file mode 100644 index 0000000..b67dad9 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultTaskMessageHandler.cs @@ -0,0 +1,55 @@ +/** + * 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.Tasks; +using Org.Apache.REEF.Driver.Task; +using Org.Apache.REEF.Utilities.Logging; +using Org.Apache.REEF.Tang.Annotations; +using System; + +namespace Org.Apache.REEF.Driver.Defaults +{ + /// <summary> + /// Default event handler for TaskMessage: Logging it. + /// </summary> + public class DefaultTaskMessageHandler : IObserver<ITaskMessage> + { + private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultTaskMessageHandler)); + + [Inject] + public DefaultTaskMessageHandler() + { + } + + public void OnNext(ITaskMessage value) + { + LOGGER.Log(Level.Info, "Default TaskMessage handler received message: " + value.Message); + } + + public void OnError(Exception error) + { + throw new NotImplementedException(); + } + + public void OnCompleted() + { + throw new NotImplementedException(); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultTaskRunningHandler.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultTaskRunningHandler.cs b/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultTaskRunningHandler.cs new file mode 100644 index 0000000..e356b0e --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultTaskRunningHandler.cs @@ -0,0 +1,54 @@ +/** + * 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.Task; +using Org.Apache.REEF.Utilities.Logging; +using Org.Apache.REEF.Tang.Annotations; +using System; + +namespace Org.Apache.REEF.Driver.Defaults +{ + /// <summary> + /// Default event handler for TaskRuntime: Logging it. + /// </summary> + public class DefaultTaskRunningHandler : IObserver<IRunningTask> + { + private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultTaskRunningHandler)); + + [Inject] + public DefaultTaskRunningHandler() + { + } + + public void OnNext(IRunningTask runningTask) + { + LOGGER.Log(Level.Info, "Received TaskRuntime: " + runningTask.Id); + } + + public void OnError(Exception error) + { + throw new NotImplementedException(); + } + + public void OnCompleted() + { + throw new NotImplementedException(); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultTaskSuspensionHandler.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultTaskSuspensionHandler.cs b/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultTaskSuspensionHandler.cs new file mode 100644 index 0000000..9be7147 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultTaskSuspensionHandler.cs @@ -0,0 +1,54 @@ +/** + * 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; +using Org.Apache.REEF.Utilities.Diagnostics; +using Org.Apache.REEF.Utilities.Logging; +using Org.Apache.REEF.Tang.Annotations; +using System; +using Org.Apache.REEF.Driver.Task; + +namespace Org.Apache.REEF.Driver.Defaults +{ + /// <summary> + /// Default event handler used for SuspendedTask: It crashes the driver. + /// </summary> + public class DefaultTaskSuspensionHandler : IObserver<ISuspendedTask> + { + [Inject] + public DefaultTaskSuspensionHandler() + { + } + + public void OnNext(ISuspendedTask value) + { + Exceptions.Throw(new InvalidOperationException("No handler bound for SuspendedTask: " + value.Id), Logger.GetLogger(typeof(DefaultTaskSuspensionHandler))); + } + + public void OnError(Exception error) + { + throw new NotImplementedException(); + } + + public void OnCompleted() + { + throw new NotImplementedException(); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/DriverConfigGenerator.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/DriverConfigGenerator.cs b/lang/cs/Org.Apache.REEF.Driver/DriverConfigGenerator.cs index 08cccc0..407ce1a 100644 --- a/lang/cs/Org.Apache.REEF.Driver/DriverConfigGenerator.cs +++ b/lang/cs/Org.Apache.REEF.Driver/DriverConfigGenerator.cs @@ -20,9 +20,10 @@ using System.Collections.Generic; using System.Globalization; using System.IO; -using Org.Apache.REEF.Driver.bridge; +using Org.Apache.REEF.Driver.Bridge; using Org.Apache.REEF.Utilities.Logging; using Org.Apache.REEF.Tang.Formats; +using Org.Apache.REEF.Tang.Formats.AvroConfigurationDataContract; using Org.Apache.REEF.Tang.Implementations.Configuration; using Org.Apache.REEF.Tang.Interface; using Org.Apache.REEF.Tang.Protobuf; http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/DriverManager.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/DriverManager.cs b/lang/cs/Org.Apache.REEF.Driver/DriverManager.cs index 5c3c19c..a54cf0c 100644 --- a/lang/cs/Org.Apache.REEF.Driver/DriverManager.cs +++ b/lang/cs/Org.Apache.REEF.Driver/DriverManager.cs @@ -22,10 +22,6 @@ 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.ReefProtocol; -using Org.Apache.REEF.Common.ProtoBuf.ReefServiceProto; using Org.Apache.REEF.Driver.Bridge; using Org.Apache.REEF.Driver.Evaluator; using Org.Apache.REEF.Utilities; @@ -39,6 +35,7 @@ using Org.Apache.REEF.Wake.Time.Runtime.Event; using System; using System.Collections.Generic; using System.Globalization; +using Org.Apache.REEF.Common.Protobuf.ReefProtocol; using Org.Apache.REEF.Tang.Implementations.InjectionPlan; namespace Org.Apache.REEF.Driver http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/DriverRuntimeConfiguration.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/DriverRuntimeConfiguration.cs b/lang/cs/Org.Apache.REEF.Driver/DriverRuntimeConfiguration.cs index d329ee6..9bb92ed 100644 --- a/lang/cs/Org.Apache.REEF.Driver/DriverRuntimeConfiguration.cs +++ b/lang/cs/Org.Apache.REEF.Driver/DriverRuntimeConfiguration.cs @@ -20,7 +20,6 @@ using Org.Apache.REEF.Common; using Org.Apache.REEF.Common.Api; using Org.Apache.REEF.Common.Catalog; -using Org.Apache.REEF.Common.Client; using Org.Apache.REEF.Common.Evaluator; using Org.Apache.REEF.Driver.Evaluator; using Org.Apache.REEF.Tang.Formats; http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Evaluator/EvaluatorDescriptorImpl.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Evaluator/EvaluatorDescriptorImpl.cs b/lang/cs/Org.Apache.REEF.Driver/Evaluator/EvaluatorDescriptorImpl.cs new file mode 100644 index 0000000..0833431 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Evaluator/EvaluatorDescriptorImpl.cs @@ -0,0 +1,218 @@ +/** + * 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.Catalog; +using Org.Apache.REEF.Common.Evaluator; +using Org.Apache.REEF.Driver.Bridge; +using Org.Apache.REEF.Utilities.Diagnostics; +using Org.Apache.REEF.Utilities.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; + +namespace Org.Apache.REEF.Driver.Evaluator +{ + public class EvaluatorDescriptorImpl : IEvaluatorDescriptor + { + private static readonly Logger LOGGER = Logger.GetLogger(typeof(EvaluatorDescriptorImpl)); + + private INodeDescriptor _nodeDescriptor; + + private EvaluatorType _type; + + private int _megaBytes; + + private int _virtualCore; + + private string _rack = "default_rack"; + + public EvaluatorDescriptorImpl(string serializedString) + { + FromString(serializedString); + } + + public EvaluatorDescriptorImpl(INodeDescriptor nodeDescriptor, EvaluatorType type, int megaBytes, int core) + { + _nodeDescriptor = nodeDescriptor; + _type = type; + _megaBytes = megaBytes; + _virtualCore = core; + } + + public INodeDescriptor NodeDescriptor + { + get + { + return _nodeDescriptor; + } + + set + { + } + } + + public EvaluatorType EvaluatorType + { + get + { + return _type; + } + + set + { + } + } + + public int Memory + { + get + { + return _megaBytes; + } + + set + { + } + } + + public int VirtualCore + { + get + { + return _virtualCore; + } + + set + { + } + } + + public string Rack + { + get + { + return _rack; + } + + set + { + } + } + + public void FromString(string str) + { + Dictionary<string, string> settings = new Dictionary<string, string>(); + string[] components = str.Split(','); + foreach (string component in components) + { + string[] pair = component.Trim().Split('='); + if (pair == null || pair.Length != 2) + { + var e = new ArgumentException("invalid component to be used as key-value pair:", component); + Exceptions.Throw(e, LOGGER); + } + settings.Add(pair[0], pair[1]); + } + string ipAddress; + if (!settings.TryGetValue("IP", out ipAddress)) + { + Exceptions.Throw(new ArgumentException("cannot find IP entry"), LOGGER); + } + ipAddress = ipAddress.Split('/').Last(); + string port; + if (!settings.TryGetValue("Port", out port)) + { + Exceptions.Throw(new ArgumentException("cannot find Port entry"), LOGGER); + } + int portNumber = 0; + int.TryParse(port, out portNumber); + string hostName; + if (!settings.TryGetValue("HostName", out hostName)) + { + Exceptions.Throw(new ArgumentException("cannot find HostName entry"), LOGGER); + } + string memory; + if (!settings.TryGetValue("Memory", out memory)) + { + Exceptions.Throw(new ArgumentException("cannot find Memory entry"), LOGGER); + } + int memoryInMegaBytes = 0; + int.TryParse(memory, out memoryInMegaBytes); + + string core; + if (!settings.TryGetValue("Core", out core)) + { + Exceptions.Throw(new ArgumentException("cannot find Core entry"), LOGGER); + } + int vCore = 0; + int.TryParse(core, out vCore); + + IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Parse(ipAddress), portNumber); + + _nodeDescriptor = new NodeDescriptorImpl(); + _nodeDescriptor.InetSocketAddress = ipEndPoint; + _nodeDescriptor.HostName = hostName; + _type = EvaluatorType.CLR; + _megaBytes = memoryInMegaBytes; + _virtualCore = vCore; + } + + public void SetType(EvaluatorType type) + { + lock (this) + { + if (_type != EvaluatorType.UNDECIDED) + { + var e = new InvalidOperationException("Cannot change a set evaluator type: " + _type); + Exceptions.Throw(e, LOGGER); + } + _type = type; + } + } + + public override bool Equals(object obj) + { + EvaluatorDescriptorImpl other = obj as EvaluatorDescriptorImpl; + if (other == null) + { + return false; + } + + return EquivalentMemory(other); + // we don't care about rack now; + // && string.Equals(_rack, other.Rack, StringComparison.OrdinalIgnoreCase); + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + + private bool EquivalentMemory(EvaluatorDescriptorImpl other) + { + int granularity = ClrHandlerHelper.MemoryGranularity == 0 + ? Constants.DefaultMemoryGranularity + : ClrHandlerHelper.MemoryGranularity; + int m1 = (Memory - 1) / granularity; + int m2 = (other.Memory - 1 ) / granularity; + return (m1 == m2); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Evaluator/EvaluatorRequest.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Evaluator/EvaluatorRequest.cs b/lang/cs/Org.Apache.REEF.Driver/Evaluator/EvaluatorRequest.cs new file mode 100644 index 0000000..3132bc7 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Evaluator/EvaluatorRequest.cs @@ -0,0 +1,107 @@ +/** + * 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.Runtime.Serialization; +using Org.Apache.REEF.Common.Catalog; +using Org.Apache.REEF.Common.Catalog.Capabilities; + +namespace Org.Apache.REEF.Driver.Evaluator +{ + [DataContract] + public class EvaluatorRequest : IEvaluatorRequest + { + public EvaluatorRequest() + : this(0, 0, 1, string.Empty, Guid.NewGuid().ToString("N")) + { + } + + public EvaluatorRequest(int number, int megaBytes) + : this(number, megaBytes, 1, string.Empty, Guid.NewGuid().ToString("N")) + { + } + + public EvaluatorRequest(int number, int megaBytes, int core) + : this(number, megaBytes, core, string.Empty, Guid.NewGuid().ToString("N")) + { + } + + public EvaluatorRequest(int number, int megaBytes, string rack) + : this(number, megaBytes, 1, rack, Guid.NewGuid().ToString("N")) + { + } + + public EvaluatorRequest(int number, int megaBytes, int core, string rack) + : this(number, megaBytes, core, rack, Guid.NewGuid().ToString("N")) + { + } + + public EvaluatorRequest(int number, int megaBytes, int core, string rack, string evaluatorBatchId) + { + Number = number; + MemoryMegaBytes = megaBytes; + VirtualCore = core; + Rack = rack; + EvaluatorBatchId = evaluatorBatchId; + } + + public EvaluatorRequest(int number, int megaBytes, int core, List<ICapability> capabilitieses, IResourceCatalog catalog) + { + Number = number; + MemoryMegaBytes = megaBytes; + Capabilities = capabilitieses; + VirtualCore = core; + Catalog = catalog; + EvaluatorBatchId = Guid.NewGuid().ToString("N"); + } + + [DataMember] + public string InstanceId { get; set; } + + [DataMember] + public int MemoryMegaBytes { get; set; } + + [DataMember] + public int Number { get; set; } + + [DataMember] + public int VirtualCore { get; set; } + + [DataMember] + public string Rack { get; set; } + + [DataMember] + public string EvaluatorBatchId { get; set; } + + public List<ICapability> Capabilities { get; set; } + + public IResourceCatalog Catalog { get; set; } + + public static EvaluatorRequestBuilder NewBuilder() + { + return new EvaluatorRequestBuilder(); + } + + public static EvaluatorRequestBuilder NewBuilder(EvaluatorRequest request) + { + return new EvaluatorRequestBuilder(request); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Evaluator/EvaluatorRequestBuilder.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Evaluator/EvaluatorRequestBuilder.cs b/lang/cs/Org.Apache.REEF.Driver/Evaluator/EvaluatorRequestBuilder.cs new file mode 100644 index 0000000..e51e799 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Evaluator/EvaluatorRequestBuilder.cs @@ -0,0 +1,60 @@ +/** + * 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.Catalog.Capabilities; +using Org.Apache.REEF.Common.Catalog; +using Org.Apache.REEF.Driver.Bridge; +using System.Collections.Generic; + +namespace Org.Apache.REEF.Driver.Evaluator +{ + public class EvaluatorRequestBuilder + { + public EvaluatorRequestBuilder(EvaluatorRequest request) + { + foreach (ICapability capability in request.Capabilities) + { + Capabilities.Add(capability); + } + Number = request.Number; + Catalog = request.Catalog; + MegaBytes = request.MemoryMegaBytes; + VirtualCore = request.VirtualCore; + } + + internal EvaluatorRequestBuilder() + { + } + + public int Number { get; set; } + + public List<ICapability> Capabilities { get; set; } + + public IResourceCatalog Catalog { get; set; } + + public int MegaBytes { get; set; } + + public int VirtualCore { get; set; } + + public EvaluatorRequest Build() + { + return new EvaluatorRequest(Number, MegaBytes, VirtualCore, Capabilities, Catalog); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Evaluator/IAllocatedEvaluator.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Evaluator/IAllocatedEvaluator.cs b/lang/cs/Org.Apache.REEF.Driver/Evaluator/IAllocatedEvaluator.cs new file mode 100644 index 0000000..794987f --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Evaluator/IAllocatedEvaluator.cs @@ -0,0 +1,55 @@ +/** + * 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; +using Org.Apache.REEF.Common.Evaluator; +using Org.Apache.REEF.Utilities; +using System; +using System.Net; + +namespace Org.Apache.REEF.Driver.Evaluator +{ + /// <summary> + /// Represents an Evaluator that is allocated, but is not running yet. + /// </summary> + public interface IAllocatedEvaluator : IDisposable, IIdentifiable, IContextSubmittable, IContextAndTaskSubmittable + { + EvaluatorType Type { get; set; } + + string NameServerInfo { get; set; } + + string EvaluatorBatchId { get; set; } + + IEvaluatorDescriptor GetEvaluatorDescriptor(); + + /// <summary> + /// Puts the given file into the working directory of the Evaluator. + /// </summary> + /// <param name="file">the file to be copied</param> + void AddFile(string file); + + /// <summary> + /// Puts the given file into the working directory of the Evaluator and adds it to its classpath. + /// </summary> + /// <param name="file">the file to be copied</param> + void AddLibrary(string file); + + void AddFileResource(string file); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Evaluator/ICompletedEvaluator.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Evaluator/ICompletedEvaluator.cs b/lang/cs/Org.Apache.REEF.Driver/Evaluator/ICompletedEvaluator.cs new file mode 100644 index 0000000..a4b3a69 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Evaluator/ICompletedEvaluator.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. + */ + +using Org.Apache.REEF.Utilities; + +namespace Org.Apache.REEF.Driver.Evaluator +{ + /// <summary> + /// Represents an Evaluator that has completed + /// </summary> + public interface ICompletedEvaluator : IIdentifiable + { + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Evaluator/IEvaluatorDescriptor.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Evaluator/IEvaluatorDescriptor.cs b/lang/cs/Org.Apache.REEF.Driver/Evaluator/IEvaluatorDescriptor.cs new file mode 100644 index 0000000..9fadbd9 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Evaluator/IEvaluatorDescriptor.cs @@ -0,0 +1,57 @@ +/** + * 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.Catalog; +using Org.Apache.REEF.Common.Evaluator; + +namespace Org.Apache.REEF.Driver.Evaluator +{ + /// <summary> + /// Metadata about an Evaluator. + /// </summary> + public interface IEvaluatorDescriptor + { + /// <summary> + /// NodeDescriptor of the node where this Evaluator is running. + /// </summary> + INodeDescriptor NodeDescriptor { get; set; } + + /// <summary> + /// type of Evaluator. + /// </summary> + EvaluatorType EvaluatorType { get; set; } + + /// <summary> + /// the amount of memory allocated to this Evaluator. + /// </summary> + int Memory { get; set; } + + /// <summary> + /// the virtual core allocated to this Evaluator. + /// </summary> + int VirtualCore { get; set; } + + /// <summary> + /// rack on which the evaluator was allocated + /// </summary> + string Rack { get; set; } + + void FromString(string str); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Evaluator/IEvaluatorRequest .cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Evaluator/IEvaluatorRequest .cs b/lang/cs/Org.Apache.REEF.Driver/Evaluator/IEvaluatorRequest .cs new file mode 100644 index 0000000..635c1f4 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Evaluator/IEvaluatorRequest .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.Common.Catalog.Capabilities; +using Org.Apache.REEF.Common.Catalog; +using System.Collections.Generic; + +namespace Org.Apache.REEF.Driver.Evaluator +{ + public interface IEvaluatorRequest + { + int MemoryMegaBytes { get; set; } + + int Number { get; set; } + + int VirtualCore { get; set; } + + string Rack { get; set; } + + string EvaluatorBatchId { get; set; } + + List<ICapability> Capabilities { get; set; } + + IResourceCatalog Catalog { get; set; } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Evaluator/IEvaluatorRequestor.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Evaluator/IEvaluatorRequestor.cs b/lang/cs/Org.Apache.REEF.Driver/Evaluator/IEvaluatorRequestor.cs new file mode 100644 index 0000000..ac374ce --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Evaluator/IEvaluatorRequestor.cs @@ -0,0 +1,47 @@ +/** + * 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.Collections.Generic; + +using Org.Apache.REEF.Common.Catalog; + +namespace Org.Apache.REEF.Driver.Evaluator +{ + /// <summary> + /// Interface through which Evaluators can be requested. + /// </summary> + public interface IEvaluatorRequestor + { + /// <summary> + /// Access to the {@link ResourceCatalog} for the cluster this Factory has access to + /// </summary> + IResourceCatalog ResourceCatalog { get; set; } + + /// <summary> + /// Map between user evaluator id and evaluator information + /// </summary> + //IDictionary<string, IEvaluatorDescriptor> Evaluators { get; } + + /// <summary> + /// Submit the request for new evaluator. The response will surface in the AllocatedEvaluator message handler. + /// </summary> + /// <param name="request"></param> + void Submit(IEvaluatorRequest request); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Evaluator/IFailedEvaluator.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Evaluator/IFailedEvaluator.cs b/lang/cs/Org.Apache.REEF.Driver/Evaluator/IFailedEvaluator.cs new file mode 100644 index 0000000..d514e97 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Evaluator/IFailedEvaluator.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.Common.Exceptions; +using Org.Apache.REEF.Driver.Bridge; +using Org.Apache.REEF.Driver.Task; +using Org.Apache.REEF.Utilities; +using System.Collections.Generic; +using Org.Apache.REEF.Driver.Bridge.Events; + +namespace Org.Apache.REEF.Driver.Evaluator +{ + /// <summary> + /// Represents an Evaluator that became unavailable. + /// </summary> + public interface IFailedEvaluator : IIdentifiable + { + EvaluatorException EvaluatorException { get; set; } + + List<FailedContext> FailedContexts { get; set; } + + Optional<IFailedTask> FailedTask { get; set; } + + IEvaluatorRequestor GetEvaluatorRequetor(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/EvaluatorManager.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/EvaluatorManager.cs b/lang/cs/Org.Apache.REEF.Driver/EvaluatorManager.cs index b8ebef9..ed5c5ac 100644 --- a/lang/cs/Org.Apache.REEF.Driver/EvaluatorManager.cs +++ b/lang/cs/Org.Apache.REEF.Driver/EvaluatorManager.cs @@ -21,9 +21,6 @@ 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; @@ -39,8 +36,9 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; - -using TaskMessage = Org.Apache.REEF.Tasks.TaskMessage; +using Org.Apache.REEF.Common.Protobuf.ReefProtocol; +using Org.Apache.REEF.Driver.Bridge.Events; +using TaskMessage = Org.Apache.REEF.Common.Tasks.TaskMessage; namespace Org.Apache.REEF.Driver { http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Org.Apache.REEF.Driver.csproj ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Org.Apache.REEF.Driver.csproj b/lang/cs/Org.Apache.REEF.Driver/Org.Apache.REEF.Driver.csproj index 8512128..0adf8e0 100644 --- a/lang/cs/Org.Apache.REEF.Driver/Org.Apache.REEF.Driver.csproj +++ b/lang/cs/Org.Apache.REEF.Driver/Org.Apache.REEF.Driver.csproj @@ -27,7 +27,7 @@ under the License. <AssemblyName>Org.Apache.REEF.Driver</AssemblyName> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> - <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\..</SolutionDir> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir> <RestorePackages>true</RestorePackages> </PropertyGroup> <Import Project="$(SolutionDir)\build.props" /> @@ -89,83 +89,83 @@ under the License. <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="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="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" /> @@ -173,25 +173,25 @@ under the License. <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="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" /> + <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" /> @@ -209,7 +209,7 @@ under the License. <Project>{79e7f89a-1dfb-45e1-8d43-d71a954aeb98}</Project> <Name>Org.Apache.REEF.Utilities</Name> </ProjectReference> - <ProjectReference Include="..\Org.Apache.REEF.Wake\Org.Apache.REEF.Wake.csproj"> + <ProjectReference Include="$(SolutionDir)\Org.Apache.REEF.Wake\Org.Apache.REEF.Wake.csproj"> <Project>{cdfb3464-4041-42b1-9271-83af24cd5008}</Project> <Name>Org.Apache.REEF.Wake</Name> </ProjectReference> http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Task/ICompletedTask.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Task/ICompletedTask.cs b/lang/cs/Org.Apache.REEF.Driver/Task/ICompletedTask.cs new file mode 100644 index 0000000..bfd15c7 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Task/ICompletedTask.cs @@ -0,0 +1,29 @@ +/** + * 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.Context; +using Org.Apache.REEF.Utilities; + +namespace Org.Apache.REEF.Driver.Task +{ + public interface ICompletedTask : IMessage, IIdentifiable + { + IActiveContext ActiveContext { get; set; } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Task/IFailedTask.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Task/IFailedTask.cs b/lang/cs/Org.Apache.REEF.Driver/Task/IFailedTask.cs new file mode 100644 index 0000000..6d12993 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Task/IFailedTask.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. + */ + +using Org.Apache.REEF.Common.Api; +using Org.Apache.REEF.Driver.Context; +using Org.Apache.REEF.Utilities; + +namespace Org.Apache.REEF.Driver.Task +{ + public interface IFailedTask : IAbstractFailure + { + Optional<IActiveContext> GetActiveContext(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Task/IRunningTask.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Task/IRunningTask.cs b/lang/cs/Org.Apache.REEF.Driver/Task/IRunningTask.cs new file mode 100644 index 0000000..f1c4ea0 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Task/IRunningTask.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 Org.Apache.REEF.Driver.Context; +using Org.Apache.REEF.Utilities; +using System; + +namespace Org.Apache.REEF.Driver.Task +{ + /// <summary> + /// Represents a running Task + /// </summary> + public interface IRunningTask : IIdentifiable, IDisposable + { + /// <summary> + /// the context the task is running on. + /// </summary> + IActiveContext ActiveContext { get; set; } + + /// <summary> + /// Sends the message to the running task. + /// </summary> + /// <param name="message"></param> + void OnNext(byte[] message); + + /// <summary> + /// Sends the message + /// </summary> + /// <param name="message"></param> + void Send(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.Driver/Task/ISuspendedTask.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Task/ISuspendedTask.cs b/lang/cs/Org.Apache.REEF.Driver/Task/ISuspendedTask.cs new file mode 100644 index 0000000..6478c8f --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Task/ISuspendedTask.cs @@ -0,0 +1,29 @@ +/** + * 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.Context; +using Org.Apache.REEF.Utilities; + +namespace Org.Apache.REEF.Driver.Task +{ + public interface ISuspendedTask : IMessage, IIdentifiable + { + IActiveContext ActiveContext { get; set; } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Task/ITaskMessage.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Task/ITaskMessage.cs b/lang/cs/Org.Apache.REEF.Driver/Task/ITaskMessage.cs new file mode 100644 index 0000000..e06c8f3 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Task/ITaskMessage.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.Task +{ + public interface ITaskMessage + { + byte[] Message { get; set; } + + string TaskId { get; set; } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7edb8570/lang/cs/Org.Apache.REEF.Driver/Task/RunningTaskImpl.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Task/RunningTaskImpl.cs b/lang/cs/Org.Apache.REEF.Driver/Task/RunningTaskImpl.cs new file mode 100644 index 0000000..abb771e --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Task/RunningTaskImpl.cs @@ -0,0 +1,127 @@ +/** + * 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; +using Org.Apache.REEF.Driver.Context; +using Org.Apache.REEF.Utilities.Logging; +using System.Globalization; +using Org.Apache.REEF.Common.Protobuf.ReefProtocol; + +namespace Org.Apache.REEF.Driver.Task +{ + public class RunningTaskImpl : IRunningTask + { + private static readonly Logger LOGGER = Logger.GetLogger(typeof(RunningTaskImpl)); + + private string _id; + + private EvaluatorManager _evaluatorManager; + + private EvaluatorContext _evaluatorContext; + + public RunningTaskImpl(EvaluatorManager evaluatorManager, string taskId, EvaluatorContext evaluatorContext) + { + LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "INIT: TaskRuntime id [{0}] on evaluator id [{1}]", taskId, evaluatorManager.Id)); + _id = taskId; + _evaluatorManager = evaluatorManager; + _evaluatorContext = evaluatorContext; + } + + public string Id + { + get + { + return _id; + } + + set + { + } + } + + public IActiveContext ActiveContext + { + get + { + return _evaluatorContext; + } + + set + { + } + } + + public void Dispose() + { + LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "DISPOSE: TaskRuntime id [{0}] on evaluator id [{1}]", _id, _evaluatorManager.Id)); + ContextControlProto contextControlProto = new ContextControlProto(); + contextControlProto.stop_task = new StopTaskProto(); + _evaluatorManager.Handle(contextControlProto); + } + + public void Dispose(byte[] message) + { + LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "DISPOSE: TaskRuntime id [{0}] on evaluator id [{1}] with message", _id, _evaluatorManager.Id)); + ContextControlProto contextControlProto = new ContextControlProto(); + contextControlProto.stop_task = new StopTaskProto(); + contextControlProto.task_message = message; + _evaluatorManager.Handle(contextControlProto); + } + + public void OnNext(byte[] message) + { + LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "MESSAGE: TaskRuntime id [{0}] on evaluator id [{1}]", _id, _evaluatorManager.Id)); + ContextControlProto contextControlProto = new ContextControlProto(); + contextControlProto.task_message = message; + _evaluatorManager.Handle(contextControlProto); + } + + public void Suspend(byte[] message) + { + LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "SUSPEND: TaskRuntime id [{0}] on evaluator id [{1}] with message", _id, _evaluatorManager.Id)); + ContextControlProto contextControlProto = new ContextControlProto(); + contextControlProto.suspend_task = new SuspendTaskProto(); + contextControlProto.task_message = message; + _evaluatorManager.Handle(contextControlProto); + } + + public void Suspend() + { + LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "SUSPEND: TaskRuntime id [{0}] on evaluator id [{1}]", _id, _evaluatorManager.Id)); + ContextControlProto contextControlProto = new ContextControlProto(); + contextControlProto.suspend_task = new SuspendTaskProto(); + _evaluatorManager.Handle(contextControlProto); + } + + public override string ToString() + { + return "TaskRuntime with taskId = " + _id; + } + + public override int GetHashCode() + { + return _id.GetHashCode(); + } + + public void Send(byte[] message) + { + LOGGER.Log(Level.Info, "RunningTaskImpl.Send() is called"); + } + } +} 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 deleted file mode 100644 index 3e2dada..0000000 --- a/lang/cs/Org.Apache.REEF.Driver/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); - } - } -}
