http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/bridge/IHttpMessage.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/bridge/IHttpMessage.cs b/lang/cs/Org.Apache.REEF.Driver/bridge/IHttpMessage.cs new file mode 100644 index 0000000..155d7ab --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/bridge/IHttpMessage.cs @@ -0,0 +1,33 @@ +/** + * 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 +{ + public interface IHttpMessage + { + string GetRequestString(); + + void SetQueryResult(string responseString); + + byte[] GetQueryReuestData(); + + void SetQueryResponseData(byte[] responseData); + + void SetUriSpecification(string uriSpecification); + } +}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/bridge/ReefHttpRequest.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/bridge/ReefHttpRequest.cs b/lang/cs/Org.Apache.REEF.Driver/bridge/ReefHttpRequest.cs new file mode 100644 index 0000000..97c0465 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/bridge/ReefHttpRequest.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.Globalization; + +namespace Org.Apache.REEF.Driver.Bridge +{ + public enum HttpMethod + { + Post, + Put, + Get, + Delete + } + + public class ReefHttpRequest + { + public HttpMethod Method { get; set; } + + public string Url { get; set; } + + public string Querystring { get; set; } + + public byte[] InputStream { get; set; } + + public string PathInfo { get; set; } + + public string Tostring() + { + return string.Format(CultureInfo.InvariantCulture, "Url: {0}, query string {1}", Url, Querystring); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/bridge/ReefHttpResponse.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/bridge/ReefHttpResponse.cs b/lang/cs/Org.Apache.REEF.Driver/bridge/ReefHttpResponse.cs new file mode 100644 index 0000000..73b64cc --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/bridge/ReefHttpResponse.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 System.Net; + +namespace Org.Apache.REEF.Driver.Bridge +{ + public class ReefHttpResponse + { + public byte[] OutputStream { get; set; } + + public HttpStatusCode Status { get; set; } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/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..3a57b0a --- /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 +{ + 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/c1b5200f/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..9bf6c09 --- /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 +{ + 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/c1b5200f/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..88b1ca2 --- /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 +{ + public interface IClosedContextClr2Java : IClr2Java + { + string GetId(); + + string GetEvaluatorId(); + + IEvaluatorDescriptor GetEvaluatorDescriptor(); + + IActiveContextClr2Java GetParentContext(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/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..ec565cd --- /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 +{ + public interface IClr2Java + { + void OnError(string message); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/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..a80c2fd --- /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 +{ + 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/c1b5200f/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..25024b3 --- /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 +{ + public interface ICompletedTaskClr2Java : IClr2Java + { + IActiveContextClr2Java GetActiveContext(); + + string GetId(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/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..c98f03e --- /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 +{ + public interface IContextMessageClr2Java : IClr2Java + { + byte[] Get(); + + string GetId(); + + string GetMessageSourceId(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/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..2ff1198 --- /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 +{ + public interface IEvaluatorRequestorClr2Java : IClr2Java + { + void Submit(IEvaluatorRequest evaluatorRequest); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/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..db145aa --- /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 +{ + 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/c1b5200f/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..2199ab3 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/bridge/clr2java/IFailedEvaluatorClr2Java.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.Driver.Bridge; + +namespace Org.Apache.REEF.Driver +{ + public interface IFailedEvaluatorClr2Java + { + IEvaluatorRequestorClr2Java GetEvaluatorRequestor(); + + string GetId(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/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..eb9c7a7 --- /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 +{ + public interface IFailedTaskClr2Java : IClr2Java + { + IActiveContextClr2Java GetActiveContext(); + + string GetString(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/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..816aa35 --- /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 +{ + 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/c1b5200f/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..4afbf2a --- /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 +{ + public interface IRunningTaskClr2Java : IClr2Java + { + IActiveContextClr2Java GetActiveContext(); + + string GetId(); + + void Send(byte[] message); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/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..612bc10 --- /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 +{ + 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/c1b5200f/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..62ba763 --- /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 +{ + public interface ITaskMessageClr2Java : IClr2Java + { + string GetId(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/bridge/events/ActiveContext.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/bridge/events/ActiveContext.cs b/lang/cs/Org.Apache.REEF.Driver/bridge/events/ActiveContext.cs new file mode 100644 index 0000000..9236141 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/bridge/events/ActiveContext.cs @@ -0,0 +1,117 @@ +/** + * 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.Driver.Evaluator; +using Org.Apache.REEF.Utilities; +using Org.Apache.REEF.Utilities.Logging; +using Org.Apache.REEF.Tang.Formats; +using Org.Apache.REEF.Tang.Interface; +using System; +using System.Runtime.Serialization; + +namespace Org.Apache.REEF.Driver.Bridge +{ + [DataContract] + internal class ActiveContext : IActiveContext + { + private static readonly Logger LOGGER = Logger.GetLogger(typeof(ActiveContext)); + + private readonly AvroConfigurationSerializer _serializer; + + public ActiveContext(IActiveContextClr2Java clr2Java) + { + InstanceId = Guid.NewGuid().ToString("N"); + Clr2Java = clr2Java; + _serializer = new AvroConfigurationSerializer(); + } + + [DataMember] + public string InstanceId { get; set; } + + public string Id + { + get + { + return Clr2Java.GetId(); + } + + set + { + } + } + + public string EvaluatorId + { + get + { + return Clr2Java.GetEvaluatorId(); + } + + set + { + } + } + + public Optional<string> ParentId { get; set; } + + public IEvaluatorDescriptor EvaluatorDescriptor + { + get + { + return Clr2Java.GetEvaluatorDescriptor(); + } + + set + { + } + } + + private IActiveContextClr2Java Clr2Java { get; set; } + + public void SubmitTask(IConfiguration taskConfiguration) + { + LOGGER.Log(Level.Info, "ActiveContext::SubmitTask"); + string task = _serializer.ToString(taskConfiguration); + LOGGER.Log(Level.Info, "serialized taskConfiguration: " + task); + Clr2Java.SubmitTask(task); + } + + public void Dispose() + { + LOGGER.Log(Level.Info, "ActiveContext::Dispose"); + Clr2Java.Close(); + } + + public void SubmitContext(IConfiguration contextConfiguration) + { + throw new NotImplementedException(); + } + + public void SubmitContextAndService(IConfiguration contextConfiguration, IConfiguration serviceConfiguration) + { + throw new NotImplementedException(); + } + + public void SendMessage(byte[] message) + { + throw new NotImplementedException(); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/bridge/events/AllocatedEvaluator.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/bridge/events/AllocatedEvaluator.cs b/lang/cs/Org.Apache.REEF.Driver/bridge/events/AllocatedEvaluator.cs new file mode 100644 index 0000000..10175e3 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/bridge/events/AllocatedEvaluator.cs @@ -0,0 +1,175 @@ +/** + * 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.Evaluator; +using Org.Apache.REEF.Utilities.Logging; +using Org.Apache.REEF.Tang.Formats; +using Org.Apache.REEF.Tang.Interface; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Net; +using System.Runtime.Serialization; + +namespace Org.Apache.REEF.Driver.Bridge +{ + [DataContract] + internal class AllocatedEvaluator : IAllocatedEvaluator + { + private static readonly Logger LOGGER = Logger.GetLogger(typeof(AllocatedEvaluator)); + + private readonly AvroConfigurationSerializer _serializer; + + private IEvaluatorDescriptor _evaluatorDescriptor; + + public AllocatedEvaluator(IAllocatedEvaluaotrClr2Java clr2Java) + { + InstanceId = Guid.NewGuid().ToString("N"); + _serializer = new AvroConfigurationSerializer(); + Clr2Java = clr2Java; + Id = Clr2Java.GetId(); + ProcessNewEvaluator(); + + NameServerInfo = Clr2Java.GetNameServerInfo(); + } + + [DataMember] + public string InstanceId { get; set; } + + public string Id { get; set; } + + public string EvaluatorBatchId { get; set; } + + public EvaluatorType Type { get; set; } + + public string NameServerInfo { get; set; } + + [DataMember] + private IAllocatedEvaluaotrClr2Java Clr2Java { get; set; } + + public void SubmitContext(IConfiguration contextConfiguration) + { + LOGGER.Log(Level.Info, "AllocatedEvaluator::SubmitContext"); + string context = _serializer.ToString(contextConfiguration); + LOGGER.Log(Level.Info, "serialized contextConfiguration: " + context); + Clr2Java.SubmitContext(context); + } + + public void SubmitContextAndTask(IConfiguration contextConfiguration, IConfiguration taskConfiguration) + { + LOGGER.Log(Level.Info, "AllocatedEvaluator::SubmitContextAndTask"); + + string context = _serializer.ToString(contextConfiguration); + string task = _serializer.ToString(taskConfiguration); + + LOGGER.Log(Level.Info, "serialized contextConfiguration: " + context); + LOGGER.Log(Level.Info, "serialized taskConfiguration: " + task); + + Clr2Java.SubmitContextAndTask(context, task); + } + + public void SubmitContextAndService(IConfiguration contextConfiguration, IConfiguration serviceConfiguration) + { + LOGGER.Log(Level.Info, "AllocatedEvaluator::SubmitContextAndService"); + + string context = _serializer.ToString(contextConfiguration); + string service = _serializer.ToString(serviceConfiguration); + + LOGGER.Log(Level.Info, "serialized contextConfiguration: " + context); + LOGGER.Log(Level.Info, "serialized serviceConfiguration: " + service); + + Clr2Java.SubmitContextAndService(context, service); + } + + public void SubmitContextAndServiceAndTask(IConfiguration contextConfiguration, IConfiguration serviceConfiguration, IConfiguration taskConfiguration) + { + LOGGER.Log(Level.Info, "AllocatedEvaluator::SubmitContextAndServiceAndTask"); + + string context = _serializer.ToString(contextConfiguration); + string service = _serializer.ToString(serviceConfiguration); + string task = _serializer.ToString(taskConfiguration); + + LOGGER.Log(Level.Info, "serialized contextConfiguration: " + context); + LOGGER.Log(Level.Info, "serialized serviceConfiguration: " + service); + LOGGER.Log(Level.Info, "serialized taskConfiguration: " + task); + + Clr2Java.SubmitContextAndServiceAndTask(context, service, task); + } + + public IEvaluatorDescriptor GetEvaluatorDescriptor() + { + return _evaluatorDescriptor; + } + + public void Dispose() + { + Clr2Java.Close(); + } + + public INodeDescriptor GetNodeDescriptor() + { + throw new NotImplementedException(); + } + + public void AddFile(string file) + { + throw new NotImplementedException(); + } + + public void AddLibrary(string file) + { + throw new NotImplementedException(); + } + + public void AddFileResource(string file) + { + throw new NotImplementedException(); + } + + private void ProcessNewEvaluator() + { + _evaluatorDescriptor = Clr2Java.GetEvaluatorDescriptor(); + lock (EvaluatorRequestor.Evaluators) + { + foreach (KeyValuePair<string, IEvaluatorDescriptor> pair in EvaluatorRequestor.Evaluators) + { + if (pair.Value.Equals(_evaluatorDescriptor)) + { + string key = pair.Key; + EvaluatorRequestor.Evaluators.Remove(key); + string assignedId = key.Substring(0, key.LastIndexOf('_')); + string message = string.Format( + CultureInfo.InvariantCulture, + "Received evalautor [{0}] of memory {1}MB that matches request of {2}MB with batch id [{3}].", + Id, + _evaluatorDescriptor.Memory, + pair.Value.Memory, + assignedId); + + LOGGER.Log(Level.Verbose, message); + EvaluatorBatchId = assignedId; + break; + } + } + } + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/bridge/events/ClosedContext.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/bridge/events/ClosedContext.cs b/lang/cs/Org.Apache.REEF.Driver/bridge/events/ClosedContext.cs new file mode 100644 index 0000000..9ea7d41 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/bridge/events/ClosedContext.cs @@ -0,0 +1,98 @@ +/** + * 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.Driver.Evaluator; +using Org.Apache.REEF.Utilities; +using System; +using System.Runtime.Serialization; + +namespace Org.Apache.REEF.Driver.Bridge +{ + public class ClosedContext : IClosedContext + { + private string _id; + + private string _evaluatorId; + + public ClosedContext(IClosedContextClr2Java clr2java) + { + InstanceId = Guid.NewGuid().ToString("N"); + _id = clr2java.GetId(); + _evaluatorId = clr2java.GetEvaluatorId(); + } + + [DataMember] + public string InstanceId { get; set; } + + public string Id + { + get + { + return _id; + } + + set + { + } + } + + public string EvaluatorId + { + get + { + return _evaluatorId; + } + + set + { + } + } + + public Optional<string> ParentId { get; set; } + + public IEvaluatorDescriptor EvaluatorDescriptor + { + get + { + return ClosedContextClr2JavaClr2Java.GetEvaluatorDescriptor(); + } + + set + { + } + } + + public IActiveContext ParentContext + { + get + { + return new ActiveContext(ParentContextClr2Java); + } + + set + { + } + } + + private IActiveContextClr2Java ParentContextClr2Java { get; set; } + + private IClosedContextClr2Java ClosedContextClr2JavaClr2Java { get; set; } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/bridge/events/CompletedEvaluator.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/bridge/events/CompletedEvaluator.cs b/lang/cs/Org.Apache.REEF.Driver/bridge/events/CompletedEvaluator.cs new file mode 100644 index 0000000..7c8866d --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/bridge/events/CompletedEvaluator.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.Driver.Evaluator; +using System; +using System.Runtime.Serialization; + +namespace Org.Apache.REEF.Driver.Bridge +{ + [DataContract] + internal class CompletedEvaluator : ICompletedEvaluator + { + private string _instanceId; + + public CompletedEvaluator(ICompletedEvaluatorClr2Java clr2Java) + { + _instanceId = Guid.NewGuid().ToString("N"); + CompletedEvaluatorClr2Java = clr2Java; + } + + [DataMember] + public string InstanceId + { + get { return _instanceId; } + set { _instanceId = value; } + } + + [DataMember] + public string Id + { + get + { + return CompletedEvaluatorClr2Java.GetId(); + } + + set + { + } + } + + [DataMember] + public ICompletedEvaluatorClr2Java CompletedEvaluatorClr2Java { get; set; } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/bridge/events/CompletedTask.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/bridge/events/CompletedTask.cs b/lang/cs/Org.Apache.REEF.Driver/bridge/events/CompletedTask.cs new file mode 100644 index 0000000..c9cf19f --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/bridge/events/CompletedTask.cs @@ -0,0 +1,75 @@ +/** + * 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.Driver.Task; +using Org.Apache.REEF.Utilities.Logging; +using System; +using System.Runtime.Serialization; + +namespace Org.Apache.REEF.Driver.Bridge +{ + [DataContract] + internal class CompletedTask : ICompletedTask + { + private static readonly Logger LOGGER = Logger.GetLogger(typeof(CompletedTask)); + + internal CompletedTask(ICompletedTaskClr2Java completedTaskClr2Java) + { + InstanceId = Guid.NewGuid().ToString("N"); + CompletedTaskClr2Java = completedTaskClr2Java; + ActiveContextClr2Java = completedTaskClr2Java.GetActiveContext(); + } + + [DataMember] + public string InstanceId { get; set; } + + public byte[] Message { get; set; } + + public string Id + { + get + { + return CompletedTaskClr2Java.GetId(); + } + + set + { + } + } + + public IActiveContext ActiveContext + { + get + { + return new ActiveContext(ActiveContextClr2Java); + } + + set + { + } + } + + [DataMember] + private ICompletedTaskClr2Java CompletedTaskClr2Java { get; set; } + + [DataMember] + private IActiveContextClr2Java ActiveContextClr2Java { get; set; } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/bridge/events/ContextMessage.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/bridge/events/ContextMessage.cs b/lang/cs/Org.Apache.REEF.Driver/bridge/events/ContextMessage.cs new file mode 100644 index 0000000..4afbcdc --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/bridge/events/ContextMessage.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.Context; + +namespace Org.Apache.REEF.Driver.Bridge +{ + public class ContextMessage : IContextMessage + { + private readonly string _messageSourcId; + private readonly byte[] _bytes; + private readonly string _id; + + public ContextMessage(IContextMessageClr2Java clr2Java) + { + _messageSourcId = clr2Java.GetMessageSourceId(); + _bytes = clr2Java.Get(); + _id = clr2Java.GetId(); + } + + public string Id + { + get { return _id; } + set { } + } + + public string MessageSourceId + { + get { return _messageSourcId; } + } + + public byte[] Message + { + get { return _bytes; } + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/bridge/events/EvaluatorRequstor.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/bridge/events/EvaluatorRequstor.cs b/lang/cs/Org.Apache.REEF.Driver/bridge/events/EvaluatorRequstor.cs new file mode 100644 index 0000000..f63c42a --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/bridge/events/EvaluatorRequstor.cs @@ -0,0 +1,95 @@ +/** + * 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.Evaluator; +using Org.Apache.REEF.Utilities.Diagnostics; +using Org.Apache.REEF.Utilities.Logging; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Runtime.Serialization; + +namespace Org.Apache.REEF.Driver.Bridge +{ + [DataContract] + internal class EvaluatorRequestor : IEvaluatorRequestor + { + private static readonly Logger LOGGER = Logger.GetLogger(typeof(EvaluatorRequestor)); + + private static Dictionary<string, IEvaluatorDescriptor> _evaluators; + + public EvaluatorRequestor(IEvaluatorRequestorClr2Java clr2Java) + { + InstanceId = Guid.NewGuid().ToString("N"); + Clr2Java = clr2Java; + } + + public static Dictionary<string, IEvaluatorDescriptor> Evaluators + { + get + { + if (_evaluators == null) + { + _evaluators = new Dictionary<string, IEvaluatorDescriptor>(); + } + return _evaluators; + } + } + + public IResourceCatalog ResourceCatalog { get; set; } + + [DataMember] + public string InstanceId { get; set; } + + [DataMember] + private IEvaluatorRequestorClr2Java Clr2Java { get; set; } + + public void Submit(IEvaluatorRequest request) + { + LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Submitting request for {0} evaluators and {1} MB memory and {2} core to rack {3}.", request.Number, request.MemoryMegaBytes, request.VirtualCore, request.Rack)); + + lock (Evaluators) + { + for (int i = 0; i < request.Number; i++) + { + EvaluatorDescriptorImpl descriptor = new EvaluatorDescriptorImpl(new NodeDescriptorImpl(), EvaluatorType.CLR, request.MemoryMegaBytes, request.VirtualCore); + descriptor.Rack = request.Rack; + string key = string.Format(CultureInfo.InvariantCulture, "{0}_{1}", request.EvaluatorBatchId, i); + try + { + _evaluators.Add(key, descriptor); + } + catch (ArgumentException e) + { + Exceptions.Caught(e, Level.Error, string.Format(CultureInfo.InvariantCulture, "EvaluatorBatchId [{0}] already exists.", key), LOGGER); + Exceptions.Throw(new InvalidOperationException("Cannot use evaluator id " + key, e), LOGGER); + } + } + } + + Clr2Java.Submit(request); + } + + public void Dispose() + { + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/bridge/events/FailedContext.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/bridge/events/FailedContext.cs b/lang/cs/Org.Apache.REEF.Driver/bridge/events/FailedContext.cs new file mode 100644 index 0000000..9e0dcc2 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/bridge/events/FailedContext.cs @@ -0,0 +1,110 @@ +/** + * 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.Driver.Evaluator; +using Org.Apache.REEF.Utilities; + +namespace Org.Apache.REEF.Driver.Bridge +{ + public class FailedContext : IFailedContext + { + private string _id; + + private string _evaluatorId; + + private string _parentId; + + public FailedContext(IFailedContextClr2Java clr2Java) + { + _id = clr2Java.GetId(); + _evaluatorId = clr2Java.GetEvaluatorId(); + _parentId = clr2Java.GetParentId(); + FailedContextClr2Java = clr2Java; + } + + public string Id + { + get + { + return _id; + } + + set + { + } + } + + public string EvaluatorId + { + get + { + return _evaluatorId; + } + + set + { + } + } + + public Optional<string> ParentId + { + get + { + return string.IsNullOrEmpty(_parentId) ? + Optional<string>.Empty() : + Optional<string>.Of(_parentId); + } + + set + { + } + } + + public IEvaluatorDescriptor EvaluatorDescriptor + { + get + { + return FailedContextClr2Java.GetEvaluatorDescriptor(); + } + + set + { + } + } + + public Optional<IActiveContext> ParentContext + { + get + { + IActiveContextClr2Java context = FailedContextClr2Java.GetParentContext(); + if (context != null) + { + return Optional<IActiveContext>.Of(new ActiveContext(context)); + } + else + { + return Optional<IActiveContext>.Empty(); + } + } + } + + private IFailedContextClr2Java FailedContextClr2Java { get; set; } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/bridge/events/FailedEvaluator.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/bridge/events/FailedEvaluator.cs b/lang/cs/Org.Apache.REEF.Driver/bridge/events/FailedEvaluator.cs new file mode 100644 index 0000000..a21c071 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/bridge/events/FailedEvaluator.cs @@ -0,0 +1,72 @@ +/** + * 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.Context; +using Org.Apache.REEF.Driver.Evaluator; +using Org.Apache.REEF.Driver.Task; +using Org.Apache.REEF.Utilities; +using Org.Apache.REEF.Utilities.Diagnostics; +using Org.Apache.REEF.Utilities.Logging; +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; + +namespace Org.Apache.REEF.Driver.Bridge +{ + [DataContract] + internal class FailedEvaluator : IFailedEvaluator + { + private static readonly Logger LOGGER = Logger.GetLogger(typeof(FailedEvaluator)); + + public FailedEvaluator(IFailedEvaluatorClr2Java clr2Java) + { + InstanceId = Guid.NewGuid().ToString("N"); + FailedEvaluatorClr2Java = clr2Java; + EvaluatorRequestorClr2Java = FailedEvaluatorClr2Java.GetEvaluatorRequestor(); + Id = FailedEvaluatorClr2Java.GetId(); + } + + [DataMember] + public string InstanceId { get; set; } + + public string Id { get; set; } + + public EvaluatorException EvaluatorException { get; set; } + + public List<FailedContext> FailedContexts { get; set; } + + public Optional<IFailedTask> FailedTask { get; set; } + + [DataMember] + private IFailedEvaluatorClr2Java FailedEvaluatorClr2Java { get; set; } + + [DataMember] + private IEvaluatorRequestorClr2Java EvaluatorRequestorClr2Java { get; set; } + + public IEvaluatorRequestor GetEvaluatorRequetor() + { + if (EvaluatorRequestorClr2Java == null) + { + Exceptions.Throw(new InvalidOperationException("EvaluatorRequestorClr2Java not initialized."), LOGGER); + } + return new EvaluatorRequestor(EvaluatorRequestorClr2Java); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/bridge/events/FailedTask.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/bridge/events/FailedTask.cs b/lang/cs/Org.Apache.REEF.Driver/bridge/events/FailedTask.cs new file mode 100644 index 0000000..0e0623a --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/bridge/events/FailedTask.cs @@ -0,0 +1,140 @@ +/** + * 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.Driver.Task; +using Org.Apache.REEF.Utilities; +using Org.Apache.REEF.Utilities.Diagnostics; +using Org.Apache.REEF.Utilities.Logging; +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; + +namespace Org.Apache.REEF.Driver.Bridge +{ + public class FailedTask : IFailedTask + { + private static readonly Logger LOGGER = Logger.GetLogger(typeof(FailedTask)); + + public FailedTask(IFailedTaskClr2Java failedTaskClr2Java) + { + InstanceId = Guid.NewGuid().ToString("N"); + Parse(failedTaskClr2Java); + FailedTaskClr2Java = failedTaskClr2Java; + ActiveContextClr2Java = failedTaskClr2Java.GetActiveContext(); + } + + public Optional<string> Reason { get; set; } + + [DataMember] + public string InstanceId { get; set; } + + public string Id { get; set; } + + public string Message { get; set; } + + public Optional<string> Description { get; set; } + + public Optional<Exception> Cause { get; set; } + + public Optional<byte[]> Data { get; set; } + + [DataMember] + private IFailedTaskClr2Java FailedTaskClr2Java { get; set; } + + [DataMember] + private IActiveContextClr2Java ActiveContextClr2Java { get; set; } + + /// <summary> + /// Access the context the task ran (and crashed) on, if it could be recovered. + /// An ActiveContext is given when the task fails but the context remains alive. + /// On context failure, the context also fails and is surfaced via the FailedContext event. + /// Note that receiving an ActiveContext here is no guarantee that the context (and evaluator) + /// are in a consistent state. Application developers need to investigate the reason available + /// via getCause() to make that call. + /// return the context the Task ran on. + /// </summary> + public Optional<IActiveContext> GetActiveContext() + { + IActiveContext activeContext = new ActiveContext(ActiveContextClr2Java); + return ActiveContextClr2Java == null ? Optional<IActiveContext>.Empty() : Optional<IActiveContext>.Of(activeContext); + } + + public Exception AsError() + { + throw new NotImplementedException(); + } + + private void Parse(IFailedTaskClr2Java failedTaskClr2Java) + { + string serializedInfo = failedTaskClr2Java.GetString(); + LOGGER.Log(Level.Verbose, "serialized failed task: " + serializedInfo); + Dictionary<string, string> settings = new Dictionary<string, string>(); + string[] components = serializedInfo.Split(','); + foreach (string component in components) + { + string[] pair = component.Trim().Split('='); + if (pair == null || pair.Length != 2) + { + Exceptions.Throw(new ArgumentException("invalid component to be used as key-value pair:", component), LOGGER); + } + settings.Add(pair[0], pair[1]); + } + + string id; + if (!settings.TryGetValue("Identifier", out id)) + { + Exceptions.Throw(new ArgumentException("cannot find Identifier entry."), LOGGER); + } + Id = id; + + string msg; + if (!settings.TryGetValue("Message", out msg)) + { + LOGGER.Log(Level.Verbose, "no Message in Failed Task."); + msg = string.Empty; + } + Message = msg; + + string description; + if (!settings.TryGetValue("Description", out description)) + { + LOGGER.Log(Level.Verbose, "no Description in Failed Task."); + description = string.Empty; + } + Description = string.IsNullOrWhiteSpace(description) ? Optional<string>.Empty() : Optional<string>.Of(description); + + string cause; + if (!settings.TryGetValue("Cause", out cause)) + { + LOGGER.Log(Level.Verbose, "no Cause in Failed Task."); + cause = string.Empty; + } + Reason = string.IsNullOrWhiteSpace(cause) ? Optional<string>.Empty() : Optional<string>.Of(cause); + + string rawData; + if (!settings.TryGetValue("Data", out rawData)) + { + LOGGER.Log(Level.Verbose, "no Data in Failed Task."); + rawData = string.Empty; + } + Data = string.IsNullOrWhiteSpace(rawData) ? Optional<byte[]>.Empty() : Optional<byte[]>.Of(ByteUtilities.StringToByteArrays(rawData)); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/bridge/events/RunningTask.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/bridge/events/RunningTask.cs b/lang/cs/Org.Apache.REEF.Driver/bridge/events/RunningTask.cs new file mode 100644 index 0000000..5c9e26c --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/bridge/events/RunningTask.cs @@ -0,0 +1,97 @@ +/** + * 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.Driver.Task; +using Org.Apache.REEF.Utilities.Logging; + +namespace Org.Apache.REEF.Driver.Bridge +{ + public class RunningTask : IRunningTask + { + private static readonly Logger LOGGER = Logger.GetLogger(typeof(RunningTask)); + private IRunningTaskClr2Java _runningTaskClr2Java; + private IActiveContextClr2Java _activeContextClr2Java; + + public RunningTask(IRunningTaskClr2Java runningTaskClr2Java) + { + using (LOGGER.LogFunction("RunningTask::RunningTask")) + { + _runningTaskClr2Java = runningTaskClr2Java; + _activeContextClr2Java = runningTaskClr2Java.GetActiveContext(); + } + } + + public Context.IActiveContext ActiveContext + { + get + { + return new ActiveContext(_activeContextClr2Java); + } + + set + { + ActiveContext = value; + } + } + + public string Id + { + get + { + return _runningTaskClr2Java.GetId(); + } + + set + { + Id = value; + } + } + + public void Send(byte[] message) + { + _runningTaskClr2Java.Send(message); + } + + public void OnNext(byte[] message) + { + throw new NotImplementedException(); + } + + public void Suspend(byte[] message) + { + throw new NotImplementedException(); + } + + public void Suspend() + { + throw new NotImplementedException(); + } + + public void Dispose(byte[] message) + { + throw new NotImplementedException(); + } + + public void Dispose() + { + throw new NotImplementedException(); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/bridge/events/SuspendedTask.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/bridge/events/SuspendedTask.cs b/lang/cs/Org.Apache.REEF.Driver/bridge/events/SuspendedTask.cs new file mode 100644 index 0000000..6c5535b --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/bridge/events/SuspendedTask.cs @@ -0,0 +1,81 @@ +/** + * 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 System; +using System.Runtime.Serialization; + +namespace Org.Apache.REEF.Driver.Bridge +{ + [DataContract] + internal class SuspendedTask : ISuspendedTask + { + internal SuspendedTask(ISuspendedTaskClr2Java suspendedTaskClr2Java) + { + InstanceId = Guid.NewGuid().ToString("N"); + SuspendedTaskClr2Java = suspendedTaskClr2Java; + ActiveContextClr2Java = suspendedTaskClr2Java.GetActiveContext(); + } + + [DataMember] + public string InstanceId { get; set; } + + public byte[] Message + { + get + { + return SuspendedTaskClr2Java.Get(); + } + + set + { + } + } + + public string Id + { + get + { + return SuspendedTaskClr2Java.GetId(); + } + + set + { + } + } + + public IActiveContext ActiveContext + { + get + { + return new ActiveContext(ActiveContextClr2Java); + } + + set + { + } + } + + [DataMember] + private ISuspendedTaskClr2Java SuspendedTaskClr2Java { get; set; } + + [DataMember] + private IActiveContextClr2Java ActiveContextClr2Java { get; set; } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/bridge/events/TaskMessage.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/bridge/events/TaskMessage.cs b/lang/cs/Org.Apache.REEF.Driver/bridge/events/TaskMessage.cs new file mode 100644 index 0000000..76250c3 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/bridge/events/TaskMessage.cs @@ -0,0 +1,64 @@ +/** + * 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 System; +using System.Runtime.Serialization; + +namespace Org.Apache.REEF.Driver.Bridge +{ + /// <summary> + /// TaskMessage which wraps ITaskMessageClr2Java + /// </summary> + [DataContract] + internal class TaskMessage : ITaskMessage + { + private ITaskMessageClr2Java _taskMessageClr2Java; + private byte[] _message; + private string _instanceId; + + public TaskMessage(ITaskMessageClr2Java clr2Java, byte[] message) + { + _instanceId = Guid.NewGuid().ToString("N"); + _taskMessageClr2Java = clr2Java; + _message = message; + } + + [DataMember] + public string InstanceId + { + get { return _instanceId; } + set { _instanceId = value; } + } + + [DataMember] + public string TaskId + { + get { return _taskMessageClr2Java.GetId(); } + set { } + } + + [DataMember] + public byte[] Message + { + get { return _message; } + set { _message = value; } + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/context/ContextConfiguration.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/context/ContextConfiguration.cs b/lang/cs/Org.Apache.REEF.Driver/context/ContextConfiguration.cs new file mode 100644 index 0000000..2fae867 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/context/ContextConfiguration.cs @@ -0,0 +1,93 @@ +/** + * 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.Events; +using Org.Apache.REEF.Tasks; +using Org.Apache.REEF.Tasks.Events; +using Org.Apache.REEF.Tang.Formats; +using Org.Apache.REEF.Tang.Util; +using System; +using System.Diagnostics.CodeAnalysis; + +[module: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "static field, typical usage in configurations")] + +namespace Org.Apache.REEF.Driver.Context +{ + public class ContextConfiguration : ConfigurationModuleBuilder + { + /// <summary> + /// The identifier of the context. + /// </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> + /// for context start. Defaults to logging if not bound. + /// </summary> + [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")] + public static readonly OptionalImpl<IObserver<IContextStart>> OnContextStart = new OptionalImpl<IObserver<IContextStart>>(); + + /// <summary> + /// for context stop. Defaults to logging if not bound. + /// </summary> + [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")] + public static readonly OptionalImpl<IObserver<IContextStop>> OnContextStop = new OptionalImpl<IObserver<IContextStop>>(); + + /// <summary> + /// to be informed right before a Task enters its call() method. + /// </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 be informed right after a Task exits its call() method. + /// </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> + /// Source of messages to be called whenever the evaluator is about to make a heartbeat. + /// </summary> + [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")] + public static readonly OptionalImpl<IContextMessageSource> OnSendMessage = new OptionalImpl<IContextMessageSource>(); + + /// <summary> + /// Driver has sent the context a message, and this parameter is used to register a handler on the context for processing that message. + /// </summary> + [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read only mutable reference types", Justification = "not applicable")] + public static readonly OptionalImpl<IContextMessageHandler> OnMessage = new OptionalImpl<IContextMessageHandler>(); + + public static ConfigurationModule ConfigurationModule + { + get + { + return new ContextConfiguration() + .BindNamedParameter(GenericType<ContextConfigurationOptions.ContextIdentifier>.Class, Identifier) + .BindSetEntry(GenericType<ContextConfigurationOptions.StartHandlers>.Class, OnContextStart) + .BindSetEntry(GenericType<ContextConfigurationOptions.StopHandlers>.Class, OnContextStop) + .BindSetEntry(GenericType<ContextConfigurationOptions.ContextMessageSources>.Class, OnSendMessage) + .BindSetEntry(GenericType<ContextConfigurationOptions.ContextMessageHandlers>.Class, OnMessage) + .BindSetEntry(GenericType<TaskConfigurationOptions.StartHandlers>.Class, OnTaskStart) + .BindSetEntry(GenericType<TaskConfigurationOptions.StopHandlers>.Class, OnTaskStop) + .Build(); + } + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/context/ContextConfigurationOptions.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/context/ContextConfigurationOptions.cs b/lang/cs/Org.Apache.REEF.Driver/context/ContextConfigurationOptions.cs new file mode 100644 index 0000000..632fdbc --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/context/ContextConfigurationOptions.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.Events; +using Org.Apache.REEF.Driver.Defaults; +using Org.Apache.REEF.Tang.Annotations; +using Org.Apache.REEF.Tang.Formats; +using System; +using System.Collections.Generic; + +namespace Org.Apache.REEF.Driver.Context +{ + /// <summary> + /// Configuration parameters for ContextConfiguration module. + /// </summary> + public class ContextConfigurationOptions : ConfigurationModuleBuilder + { + [NamedParameter(documentation: "The identifier for the context.")] + public class ContextIdentifier : Name<string> + { + } + + [NamedParameter(documentation: "The set of event handlers for the ContextStart event", defaultClasses: new[] { typeof(DefaultContextStartHandler) })] + public class StartHandlers : Name<ISet<IObserver<IContextStart>>> + { + } + + [NamedParameter(documentation: "The set of event handlers for the ContextStop event", defaultClasses: new[] { typeof(DefaultContextStopHandler) })] + public class StopHandlers : Name<ISet<IObserver<IContextStop>>> + { + } + + [NamedParameter(documentation: "The set of ContextMessageSource implementations called during heartbeats.", defaultClasses: new[] { typeof(DefaultContextMessageSource) })] + public class ContextMessageSources : Name<ISet<IContextMessageSource>> + { + } + + [NamedParameter(documentation: "The set of Context message handlers.")] + public class ContextMessageHandlers : Name<ISet<IContextMessageHandler>> + { + } + } +}
