You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@reef.apache.org by we...@apache.org on 2015/02/05 22:06:03 UTC
[42/51] [partial] incubator-reef git commit: [REEF-131] Towards the
new .Net project structure This is to change .Net project structure for Tang,
Wake, REEF utilities, Common and Driver:
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/context/EvaluatorContext.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/context/EvaluatorContext.cs b/lang/cs/Org.Apache.REEF.Driver/context/EvaluatorContext.cs
new file mode 100644
index 0000000..f275900
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/context/EvaluatorContext.cs
@@ -0,0 +1,148 @@
+/**
+ * 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.ProtoBuf.EvaluatorRunTimeProto;
+using Org.Apache.REEF.Driver.Bridge;
+using Org.Apache.REEF.Driver.Context;
+using Org.Apache.REEF.Driver.Evaluator;
+using Org.Apache.REEF.Utilities;
+using Org.Apache.REEF.Utilities.Diagnostics;
+using Org.Apache.REEF.Utilities.Logging;
+using Org.Apache.REEF.Tang.Interface;
+using System;
+using System.Globalization;
+
+namespace Org.Apache.REEF.Driver
+{
+ public class EvaluatorContext : IActiveContext
+ {
+ private static readonly Logger LOGGER = Logger.GetLogger(typeof(EvaluatorContext));
+
+ private string _identifier;
+
+ private Optional<string> _parentId;
+
+ private EvaluatorManager _evaluatorManager;
+
+ private bool _disposed = false;
+
+ public EvaluatorContext(EvaluatorManager evaluatorManager, string id, Optional<string> parentId)
+ {
+ _identifier = id;
+ _parentId = parentId;
+ _evaluatorManager = evaluatorManager;
+ }
+
+ public string Id
+ {
+ get
+ {
+ return _identifier;
+ }
+
+ set
+ {
+ }
+ }
+
+ public string EvaluatorId
+ {
+ get
+ {
+ return _evaluatorManager.Id;
+ }
+
+ set
+ {
+ }
+ }
+
+ public Optional<string> ParentId
+ {
+ get
+ {
+ return _parentId;
+ }
+
+ set
+ {
+ }
+ }
+
+ public IEvaluatorDescriptor EvaluatorDescriptor
+ {
+ get
+ {
+ return _evaluatorManager.EvaluatorDescriptor;
+ }
+
+ set
+ {
+ }
+ }
+
+ public void Dispose()
+ {
+ if (_disposed)
+ {
+ var e = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Active context [{0}] already closed", _identifier));
+ Exceptions.Throw(e, LOGGER);
+ }
+ LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Submit close context: RunningEvaluator id [{0}] for context id [{1}]", EvaluatorId, Id));
+ RemoveContextProto removeContextProto = new RemoveContextProto();
+ removeContextProto.context_id = Id;
+ ContextControlProto contextControlProto = new ContextControlProto();
+ contextControlProto.remove_context = removeContextProto;
+ _evaluatorManager.Handle(contextControlProto);
+ _disposed = true;
+ }
+
+ public ClosedContext GetClosedContext(IActiveContext parentContext)
+ {
+ //return new ClosedContext(parentContext, EvaluatorId, Id, ParentId, EvaluatorDescriptor);
+ throw new NotImplementedException();
+ }
+
+ public FailedContext GetFailedContext(Optional<IActiveContext> parentContext, Exception cause)
+ {
+ //return new FailedContext(parentContext, Id, cause, EvaluatorId, ParentId, EvaluatorDescriptor);
+ throw new NotImplementedException();
+ }
+
+ public void SubmitTask(IConfiguration taskConf)
+ {
+ throw new NotImplementedException();
+ }
+
+ 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/context/IActiveContext.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/context/IActiveContext.cs b/lang/cs/Org.Apache.REEF.Driver/context/IActiveContext.cs
new file mode 100644
index 0000000..87ae9d2
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/context/IActiveContext.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.Common;
+using System;
+
+namespace Org.Apache.REEF.Driver.Context
+{
+ public interface IActiveContext : IDisposable, IContext, ITaskSubmittable, IContextSubmittable
+ {
+ void SendMessage(byte[] message);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/context/IClosedContext.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/context/IClosedContext.cs b/lang/cs/Org.Apache.REEF.Driver/context/IClosedContext.cs
new file mode 100644
index 0000000..1fc0213
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/context/IClosedContext.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.Context
+{
+ public interface IClosedContext : IContext
+ {
+ IActiveContext ParentContext { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/context/IContext.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/context/IContext.cs b/lang/cs/Org.Apache.REEF.Driver/context/IContext.cs
new file mode 100644
index 0000000..fd6006c
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/context/IContext.cs
@@ -0,0 +1,45 @@
+/**
+ * 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;
+
+namespace Org.Apache.REEF.Driver.Context
+{
+ /// <summary>
+ /// A common base interface for Contexts, available or failed.
+ /// </summary>
+ public interface IContext : IIdentifiable
+ {
+ /// <summary>
+ /// the identifier of the Evaluator this EvaluatorContext is instantiated on.
+ /// </summary>
+ string EvaluatorId { get; set; }
+
+ /// <summary>
+ /// ID of the parent context, if there is any.
+ /// </summary>
+ Optional<string> ParentId { get; set; }
+
+ /// <summary>
+ /// descriptor of the Evaluator this Context is on.
+ /// </summary>
+ IEvaluatorDescriptor EvaluatorDescriptor { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/context/IFailedContext.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/context/IFailedContext.cs b/lang/cs/Org.Apache.REEF.Driver/context/IFailedContext.cs
new file mode 100644
index 0000000..6e07788
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/context/IFailedContext.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.Utilities;
+
+namespace Org.Apache.REEF.Driver.Context
+{
+ public interface IFailedContext : IContext
+ {
+ Optional<IActiveContext> ParentContext { get; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/context/defaults/DefaultContextMessageSource.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/context/defaults/DefaultContextMessageSource.cs b/lang/cs/Org.Apache.REEF.Driver/context/defaults/DefaultContextMessageSource.cs
new file mode 100644
index 0000000..6c762ab
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/context/defaults/DefaultContextMessageSource.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.Context;
+using Org.Apache.REEF.Utilities;
+
+namespace Org.Apache.REEF.Driver.Context
+{
+ /// <summary>
+ /// Default ContextMessageSource: return nothing.
+ /// </summary>
+ public class DefaultContextMessageSource : IContextMessageSource
+ {
+ public Optional<Common.Context.ContextMessage> Message
+ {
+ get
+ {
+ return Optional<Common.Context.ContextMessage>.Empty();
+ }
+
+ set
+ {
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/context/defaults/DefaultContextStartHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/context/defaults/DefaultContextStartHandler.cs b/lang/cs/Org.Apache.REEF.Driver/context/defaults/DefaultContextStartHandler.cs
new file mode 100644
index 0000000..f1bc157
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/context/defaults/DefaultContextStartHandler.cs
@@ -0,0 +1,48 @@
+/**
+ * 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.Events;
+using Org.Apache.REEF.Utilities.Logging;
+using System;
+
+namespace Org.Apache.REEF.Driver.Context
+{
+ /// <summary>
+ /// Default handler for ContextStart
+ /// </summary>
+ public class DefaultContextStartHandler : IObserver<IContextStart>
+ {
+ private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultContextStartHandler));
+
+ public void OnNext(IContextStart contextStart)
+ {
+ LOGGER.Log(Level.Info, "DefaultContextStartHandler received for context: " + contextStart.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/c1b5200f/lang/cs/Org.Apache.REEF.Driver/context/defaults/DefaultContextStopHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/context/defaults/DefaultContextStopHandler.cs b/lang/cs/Org.Apache.REEF.Driver/context/defaults/DefaultContextStopHandler.cs
new file mode 100644
index 0000000..82f3250
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/context/defaults/DefaultContextStopHandler.cs
@@ -0,0 +1,48 @@
+/**
+ * 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.Events;
+using Org.Apache.REEF.Utilities.Logging;
+using System;
+
+namespace Org.Apache.REEF.Driver.Context
+{
+ /// <summary>
+ /// Default event handler for ContextStop
+ /// </summary>
+ public class DefaultContextStopHandler : IObserver<IContextStop>
+ {
+ private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultContextStopHandler));
+
+ public void OnNext(IContextStop contextStop)
+ {
+ LOGGER.Log(Level.Info, "DefaultContextStopHandler received for context: " + contextStop.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/c1b5200f/lang/cs/Org.Apache.REEF.Driver/contract/IBridgeContract.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/contract/IBridgeContract.cs b/lang/cs/Org.Apache.REEF.Driver/contract/IBridgeContract.cs
new file mode 100644
index 0000000..2c08d0b
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/contract/IBridgeContract.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.Contract
+{
+ public interface IBridgeContract
+ {
+ string InstanceId { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultClientCloseHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultClientCloseHandler.cs b/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultClientCloseHandler.cs
new file mode 100644
index 0000000..a47a2b1
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultClientCloseHandler.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.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 DefaultClientCloseHandler : IObserver<byte[]>
+ {
+ private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultClientCloseHandler));
+
+ [Inject]
+ public DefaultClientCloseHandler()
+ {
+ }
+
+ public void OnNext(byte[] value)
+ {
+ LOGGER.Log(Level.Info, "Closing the Client");
+ }
+
+ 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/c1b5200f/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultClientCloseWithMessageHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultClientCloseWithMessageHandler.cs b/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultClientCloseWithMessageHandler.cs
new file mode 100644
index 0000000..0dbb6f0
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultClientCloseWithMessageHandler.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.Utilities;
+using Org.Apache.REEF.Utilities.Diagnostics;
+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: Throw an Exception.
+ /// </summary>
+ public class DefaultClientCloseWithMessageHandler : IObserver<byte[]>
+ {
+ [Inject]
+ public DefaultClientCloseWithMessageHandler()
+ {
+ }
+
+ public void OnNext(byte[] value)
+ {
+ Exceptions.Throw(new InvalidOperationException("No handler bound for client Close With Message event:" + ByteUtilities.ByteArrarysToString(value)),
+ Logger.GetLogger(typeof(DefaultClientCloseWithMessageHandler)));
+ }
+
+ 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/c1b5200f/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultClientMessageHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultClientMessageHandler.cs b/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultClientMessageHandler.cs
new file mode 100644
index 0000000..ca5ac0e
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultClientMessageHandler.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.Utilities;
+using Org.Apache.REEF.Utilities.Logging;
+using Org.Apache.REEF.Tang.Annotations;
+using System;
+
+namespace Org.Apache.REEF.Driver.Defaults
+{
+ /// <summary>
+ /// DDefault event handler for Client messages: Logging it.
+ /// </summary>
+ public class DefaultClientMessageHandler : IObserver<byte[]>
+ {
+ private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultClientMessageHandler));
+
+ [Inject]
+ public DefaultClientMessageHandler()
+ {
+ }
+
+ public void OnNext(byte[] value)
+ {
+ LOGGER.Log(Level.Info, "Received message: " + ByteUtilities.ByteArrarysToString(value));
+ }
+
+ 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/c1b5200f/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultContextActiveHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultContextActiveHandler.cs b/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultContextActiveHandler.cs
new file mode 100644
index 0000000..7bb27ad
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultContextActiveHandler.cs
@@ -0,0 +1,56 @@
+/**
+ * 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.Logging;
+using Org.Apache.REEF.Tang.Annotations;
+using System;
+using System.Globalization;
+
+namespace Org.Apache.REEF.Driver.Defaults
+{
+ /// <summary>
+ /// Default handler for ActiveContext: Close it.
+ /// </summary>
+ public class DefaultContextActiveHandler : IObserver<IActiveContext>
+ {
+ private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultContextActiveHandler));
+
+ [Inject]
+ public DefaultContextActiveHandler()
+ {
+ }
+
+ public void OnNext(IActiveContext value)
+ {
+ LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Received ActiveContext :[{0}], closing it", 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/c1b5200f/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultContextClosureHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultContextClosureHandler.cs b/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultContextClosureHandler.cs
new file mode 100644
index 0000000..aa957c7
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultContextClosureHandler.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.Context;
+using Org.Apache.REEF.Driver.Context;
+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 ClosedContext: Logging it.
+ /// </summary>
+ public class DefaultContextClosureHandler : IObserver<IClosedContext>
+ {
+ private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultContextClosureHandler));
+
+ [Inject]
+ public DefaultContextClosureHandler()
+ {
+ }
+
+ public void OnNext(IClosedContext value)
+ {
+ LOGGER.Log(Level.Info, "Received ClosedContext :" + 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/c1b5200f/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultContextFailureHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultContextFailureHandler.cs b/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultContextFailureHandler.cs
new file mode 100644
index 0000000..d8014c6
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultContextFailureHandler.cs
@@ -0,0 +1,51 @@
+/**
+ * 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.Tang.Annotations;
+using System;
+
+namespace Org.Apache.REEF.Driver.Defaults
+{
+ /// <summary>
+ /// Default event handler used for FailedContext: It crashes the driver.
+ /// </summary>
+ public class DefaultContextFailureHandler : IObserver<IFailedContext>
+ {
+ [Inject]
+ public DefaultContextFailureHandler()
+ {
+ }
+
+ public void OnNext(IFailedContext value)
+ {
+ throw new InvalidOperationException("No handler bound for FailedContext: " + 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/c1b5200f/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultContextMessageHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultContextMessageHandler.cs b/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultContextMessageHandler.cs
new file mode 100644
index 0000000..0e6715c
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultContextMessageHandler.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.Context;
+using Org.Apache.REEF.Utilities;
+using Org.Apache.REEF.Utilities.Logging;
+using Org.Apache.REEF.Tang.Annotations;
+using System;
+
+namespace Org.Apache.REEF.Driver.Defaults
+{
+ /// <summary>
+ /// efault event handler for ContextMessage: Logging it.
+ /// </summary>
+ public class DefaultContextMessageHandler : IObserver<IContextMessage>
+ {
+ private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultContextMessageHandler));
+
+ [Inject]
+ public DefaultContextMessageHandler()
+ {
+ }
+
+ public void OnNext(IContextMessage value)
+ {
+ LOGGER.Log(Level.Info, "Received ContextMessage: " + ByteUtilities.ByteArrarysToString(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/c1b5200f/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultCustomTraceListener.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultCustomTraceListener.cs b/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultCustomTraceListener.cs
new file mode 100644
index 0000000..a1f897b
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultCustomTraceListener.cs
@@ -0,0 +1,45 @@
+/**
+ * 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.Tang.Annotations;
+using System.Diagnostics;
+
+namespace Org.Apache.REEF.Driver.Defaults
+{
+ public class DefaultCustomTraceListener : TraceListener
+ {
+ private readonly TraceListener _listener;
+
+ [Inject]
+ public DefaultCustomTraceListener()
+ {
+ _listener = new ConsoleTraceListener();
+ }
+
+ public override void Write(string message)
+ {
+ _listener.Write(message);
+ }
+
+ public override void WriteLine(string message)
+ {
+ _listener.WriteLine(message);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/c1b5200f/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultDriverRestartContextActiveHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultDriverRestartContextActiveHandler.cs b/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultDriverRestartContextActiveHandler.cs
new file mode 100644
index 0000000..5ceb271
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultDriverRestartContextActiveHandler.cs
@@ -0,0 +1,56 @@
+/**
+ * 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.Logging;
+using Org.Apache.REEF.Tang.Annotations;
+using System;
+using System.Globalization;
+
+namespace Org.Apache.REEF.Driver.Defaults
+{
+ /// <summary>
+ /// Default handler for ActiveContext received during driver restart: Close it.
+ /// </summary>
+ public class DefaultDriverRestartContextActiveHandler : IObserver<IActiveContext>
+ {
+ private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultDriverRestartContextActiveHandler));
+
+ [Inject]
+ public DefaultDriverRestartContextActiveHandler()
+ {
+ }
+
+ public void OnNext(IActiveContext value)
+ {
+ LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Received ActiveContext during driver restart:[{0}], closing it", 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/c1b5200f/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultDriverRestartHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultDriverRestartHandler.cs b/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultDriverRestartHandler.cs
new file mode 100644
index 0000000..a895251
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultDriverRestartHandler.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.Utilities.Logging;
+using Org.Apache.REEF.Tang.Annotations;
+using Org.Apache.REEF.Wake.Time;
+using System;
+
+namespace Org.Apache.REEF.Driver.Defaults
+{
+ /// <summary>
+ /// Default event handler for driver restart: Logging it.
+ /// </summary>
+ public class DefaultDriverRestartHandler : IObserver<StartTime>
+ {
+ private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultDriverRestartHandler));
+
+ [Inject]
+ public DefaultDriverRestartHandler()
+ {
+ }
+
+ public void OnNext(StartTime startTime)
+ {
+ LOGGER.Log(Level.Info, "Driver restarted at" + new DateTime(startTime.TimeStamp));
+ }
+
+ 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/c1b5200f/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultDriverRestartTaskRunningHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultDriverRestartTaskRunningHandler.cs b/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultDriverRestartTaskRunningHandler.cs
new file mode 100644
index 0000000..c202933
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultDriverRestartTaskRunningHandler.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 received during driver restart: Logging it.
+ /// </summary>
+ public class DefaultDriverRestartTaskRunningHandler : IObserver<IRunningTask>
+ {
+ private static readonly Logger LOGGER = Logger.GetLogger(typeof(DefaultDriverRestartTaskRunningHandler));
+
+ [Inject]
+ public DefaultDriverRestartTaskRunningHandler()
+ {
+ }
+
+ public void OnNext(IRunningTask runningTask)
+ {
+ LOGGER.Log(Level.Info, "Received TaskRuntime during driver restart: " + 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/c1b5200f/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/c1b5200f/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/c1b5200f/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/c1b5200f/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/c1b5200f/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/c1b5200f/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..33b6495
--- /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.Task;
+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/c1b5200f/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..b39200f
--- /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.Task;
+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/c1b5200f/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..cdaac06
--- /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.Task;
+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/c1b5200f/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/c1b5200f/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..46ced71
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/defaults/DefaultTaskSuspensionHandler.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;
+using Org.Apache.REEF.Utilities.Diagnostics;
+using Org.Apache.REEF.Utilities.Logging;
+using Org.Apache.REEF.Tang.Annotations;
+using System;
+
+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/c1b5200f/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/c1b5200f/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..b04e05b
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/evaluator/EvaluatorRequest.cs
@@ -0,0 +1,108 @@
+/**
+ * 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.Capabilities;
+using Org.Apache.REEF.Common.Catalog;
+using Org.Apache.REEF.Driver.Evaluator;
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+
+namespace Org.Apache.REEF.Driver.Bridge
+{
+ [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/c1b5200f/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..95a1ee3
--- /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.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/c1b5200f/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/c1b5200f/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/c1b5200f/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);
+ }
+}