http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Types/IPackageNode.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/TANG/Tang/Types/IPackageNode.cs b/lang/cs/Source/TANG/Tang/Types/IPackageNode.cs new file mode 100644 index 0000000..9c4e0e4 --- /dev/null +++ b/lang/cs/Source/TANG/Tang/Types/IPackageNode.cs @@ -0,0 +1,24 @@ +/** + * 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.Tang.Types +{ + public interface IPackageNode : INode + { + } +}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Types/ITraversable.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/TANG/Tang/Types/ITraversable.cs b/lang/cs/Source/TANG/Tang/Types/ITraversable.cs new file mode 100644 index 0000000..cd7c3c8 --- /dev/null +++ b/lang/cs/Source/TANG/Tang/Types/ITraversable.cs @@ -0,0 +1,27 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +using System.Collections.Generic; + +namespace Org.Apache.Reef.Tang.Types +{ + public interface ITraversable<T> where T : ITraversable<T> + { + ICollection<T> GetChildren(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Util/AbstractMonotonicMultiMap.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/TANG/Tang/Util/AbstractMonotonicMultiMap.cs b/lang/cs/Source/TANG/Tang/Util/AbstractMonotonicMultiMap.cs new file mode 100644 index 0000000..3019d93 --- /dev/null +++ b/lang/cs/Source/TANG/Tang/Util/AbstractMonotonicMultiMap.cs @@ -0,0 +1,263 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using Org.Apache.Reef.Utilities.Logging; + +namespace Org.Apache.Reef.Tang.Util +{ + public abstract class AbstractMonotonicMultiMap<K, V> : ICollection<KeyValuePair<K, V>> + { + private static readonly Logger LOGGER = Logger.GetLogger(typeof(AbstractMonotonicMultiMap<K, V>)); + + private readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); + + private IDictionary<K, ISet<V>> map; + + private int size = 0; + + public AbstractMonotonicMultiMap(IDictionary<K, ISet<V>> map) + { + this.map = map; + } + + public ICollection<K> Keys + { + get { return map.Keys; } + } + + public int Count + { + get { return size; } + } + + public bool IsReadOnly + { + get { throw new NotImplementedException(); } + } + + public void Add(K key, V val) + { + _lock.EnterWriteLock(); + try + { + ISet<V> vals; + map.TryGetValue(key, out vals); + + if (vals == null) + { + vals = new MonotonicHashSet<V>(); + map.Add(key, vals); + } + vals.Add(val); + size++; + } + finally + { + if (_lock.IsWriteLockHeld) + { + _lock.ExitWriteLock(); + } + } + } + + public ISet<V> GetValuesForKey(K key) + { + _lock.EnterReadLock(); + try + { + ISet<V> ret; + map.TryGetValue(key, out ret); + if (ret == null) + { + return new MonotonicHashSet<V>(); + } + return ret; + } + finally + { + if (_lock.IsReadLockHeld) + { + _lock.ExitReadLock(); + } + } + } + + public bool Contains(K key, V val) + { + _lock.EnterReadLock(); + try + { + ISet<V> vals; + map.TryGetValue(key, out vals); + + if (vals != null) + { + return vals.Contains(val); + } + return false; + } + finally + { + if (_lock.IsReadLockHeld) + { + _lock.ExitReadLock(); + } + } + } + + public bool Add(KeyValuePair<K, V> e) + { + Add(e.Key, e.Value); + return true; + } + + public bool AddAll(ICollection<KeyValuePair<K, V>> c) // where T : KeyValuePair<K, V> + { + bool ret = false; + foreach (KeyValuePair<K, V> e in c) + { + Add(e); + ret = true; + } + return ret; + } + + public void Clear() + { + throw new NotSupportedException("MonotonicMultiMap cannot be cleared!"); + } + + public bool Contains(object o) + { + KeyValuePair<K, V> e = (KeyValuePair<K, V>)o; + return Contains((K)e.Key, (V)e.Value); + } + + public bool ContainsAll<T>(ICollection<T> c) + { + foreach (object o in c) + { + if (!Contains(o)) + { + return false; + } + } + return true; + } + + public bool IsEmpty() + { + return size == 0; + } + + public ISet<V> Values() + { + _lock.EnterReadLock(); + + try + { + ISet<V> s = new HashSet<V>(); + foreach (KeyValuePair<K, V> e in this) + { + s.Add(e.Value); + } + return s; + } + finally + { + if (_lock.IsReadLockHeld) + { + _lock.ExitReadLock(); + } + } + } + + public int Size() + { + return size; + } + + public bool ContainsKey(K k) + { + _lock.EnterReadLock(); + + try + { + if (map.ContainsKey(k)) + { + return (GetValuesForKey(k).Count != 0); + } + return false; + } + finally + { + if (_lock.IsReadLockHeld) + { + _lock.ExitReadLock(); + } + } + } + + void ICollection<KeyValuePair<K, V>>.Add(KeyValuePair<K, V> item) + { + throw new NotImplementedException(); + } + + public void CopyTo(KeyValuePair<K, V>[] array, int arrayIndex) + { + throw new NotImplementedException(); + } + + public bool Remove(KeyValuePair<K, V> item) + { + throw new NotImplementedException(); + } + + public bool Contains(KeyValuePair<K, V> item) + { + throw new NotImplementedException(); + } + + public IEnumerator<KeyValuePair<K, V>> GetEnumerator() + { + _lock.EnterReadLock(); + + try + { + return map.SelectMany(kvp => kvp.Value, (kvp, v) => new KeyValuePair<K, V>(kvp.Key, v)).GetEnumerator(); + } + finally + { + if (_lock.IsReadLockHeld) + { + _lock.ExitReadLock(); + } + } + } + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Util/AssemblyLoader.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/TANG/Tang/Util/AssemblyLoader.cs b/lang/cs/Source/TANG/Tang/Util/AssemblyLoader.cs new file mode 100644 index 0000000..8f9175c --- /dev/null +++ b/lang/cs/Source/TANG/Tang/Util/AssemblyLoader.cs @@ -0,0 +1,70 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +using System; +using System.Collections.Generic; +using System.Reflection; +using Org.Apache.Reef.Utilities.Logging; + +namespace Org.Apache.Reef.Tang.Util +{ + public class AssemblyLoader + { + private static readonly Logger LOGGER = Logger.GetLogger(typeof(AssemblyLoader)); + + public IList<Assembly> Assemblies { get; set; } + + public AssemblyLoader(string[] files) + { + Assemblies = new List<Assembly>(); + foreach (var a in files) + { + Assemblies.Add(Assembly.Load(a)); + } + } + + public Type GetType(string name) + { + Type t = Type.GetType(name); + if (t == null) + { + foreach (var a in Assemblies) + { + t = a.GetType(name); + if (t != null) + { + return t; + } + } + + foreach (var a in AppDomain.CurrentDomain.GetAssemblies()) + { + t = a.GetType(name); + if (t != null) + break; + } + } + + if (t == null) + { + Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ApplicationException("Not able to get Type from the name provided: " + name), LOGGER); + } + return t; + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Util/GenericType.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/TANG/Tang/Util/GenericType.cs b/lang/cs/Source/TANG/Tang/Util/GenericType.cs new file mode 100644 index 0000000..d6a4ea0 --- /dev/null +++ b/lang/cs/Source/TANG/Tang/Util/GenericType.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; + +namespace Org.Apache.Reef.Tang.Util +{ + public class GenericType<T> + { + public static readonly GenericType<T> Class = null; + + public Type TypeT + { + get { return typeof(T); } + } + + public override bool Equals(object obj) + { + GenericType<T> other = obj as GenericType<T>; + if (other == null) + { + return false; + } + + return TypeT == other.TypeT; + } + + public override int GetHashCode() + { + return TypeT.GetHashCode(); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Util/MonotonicHashMap.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/TANG/Tang/Util/MonotonicHashMap.cs b/lang/cs/Source/TANG/Tang/Util/MonotonicHashMap.cs new file mode 100644 index 0000000..0d1deb5 --- /dev/null +++ b/lang/cs/Source/TANG/Tang/Util/MonotonicHashMap.cs @@ -0,0 +1,83 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +using System; +using System.Collections.Generic; +using Org.Apache.Reef.Utilities.Logging; + +namespace Org.Apache.Reef.Tang.Util +{ + public class MonotonicHashMap<T, U> : Dictionary<T, U> + { + private static readonly Logger LOGGER = Logger.GetLogger(typeof(MonotonicHashMap<T, U>)); + + public new void Add(T key, U value) + { + U old; + TryGetValue(key, out old); + if (old != null) + { + var ex = new ArgumentException("Attempt to re-add: [" + key + "] old value: " + old + " new value " + value); + Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); + } + base.Add(key, value); + } + + public void AddAll(IDictionary<T, U> m) + { + foreach (T t in m.Keys) + { + if (ContainsKey(t)) + { + U old; + m.TryGetValue(t, out old); + Add(t, old); // guaranteed to throw. + } + } + foreach (T t in m.Keys) + { + U old; + m.TryGetValue(t, out old); + Add(t, old); + } + } + + public bool IsEmpty() + { + return Count == 0; + } + + public U Get(T key) + { + U val; + TryGetValue(key, out val); + return val; + } + + public new void Clear() + { + throw new NotSupportedException(); + } + + public new bool Remove(T key) + { + throw new NotSupportedException(); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Util/MonotonicHashSet.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/TANG/Tang/Util/MonotonicHashSet.cs b/lang/cs/Source/TANG/Tang/Util/MonotonicHashSet.cs new file mode 100644 index 0000000..20706ef --- /dev/null +++ b/lang/cs/Source/TANG/Tang/Util/MonotonicHashSet.cs @@ -0,0 +1,131 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using Org.Apache.Reef.Utilities.Logging; + +namespace Org.Apache.Reef.Tang.Util +{ + public class MonotonicHashSet<T> : HashSet<T> + { + private static readonly Logger LOGGER = Logger.GetLogger(typeof(MonotonicHashSet<T>)); + private readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); + + public MonotonicHashSet() + { + } + + public MonotonicHashSet(IEnumerable<T> collection) + : base(collection) + { + } + + public MonotonicHashSet(T[] collection) + : base(collection.ToList()) + { + } + + public new bool Add(T e) + { + _lock.EnterWriteLock(); + + try + { + if (Contains(e)) + { + var ex = new ArgumentException("Attempt to re-add " + e + + " to MonotonicSet!"); + Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); + } + return base.Add(e); + } + finally + { + if (_lock.IsWriteLockHeld) + { + _lock.ExitWriteLock(); + } + } + } + + public bool AddAll(ICollection<T> c) + { + _lock.EnterWriteLock(); + try + { + foreach (T t in c) + { + if (Contains(t)) + { + var ex = new ArgumentException("Attempt to re-add " + t + + " to MonotonicSet!"); + Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); + } + base.Add(t); + } + } + finally + { + if (_lock.IsWriteLockHeld) + { + _lock.ExitWriteLock(); + } + } + return c.Count != 0; + } + + public bool ContainsAll(ICollection<T> c) + { + _lock.EnterReadLock(); + + try + { + foreach (T t in c) + { + if (!Contains(t)) + { + return false; + } + } + } + finally + { + if (_lock.IsReadLockHeld) + { + _lock.ExitReadLock(); + } + } + return true; + } + + public new void Clear() + { + Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new NotSupportedException("Attempt to clear MonotonicSet!"), LOGGER); + } + + public bool Remove(object o) + { + Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new NotSupportedException("Attempt to remove " + o + " from MonotonicSet!"), LOGGER); + return false; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Util/MonotonicMultiHashMap.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/TANG/Tang/Util/MonotonicMultiHashMap.cs b/lang/cs/Source/TANG/Tang/Util/MonotonicMultiHashMap.cs new file mode 100644 index 0000000..cc039aa --- /dev/null +++ b/lang/cs/Source/TANG/Tang/Util/MonotonicMultiHashMap.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.Collections.Generic; + +namespace Org.Apache.Reef.Tang.Util +{ + public class MonotonicMultiHashMap<K, V> : AbstractMonotonicMultiMap<K, V> + { + public MonotonicMultiHashMap() : base(new MonotonicHashMap<K, ISet<V>>()) + { + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Util/MonotonicMultiMap.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/TANG/Tang/Util/MonotonicMultiMap.cs b/lang/cs/Source/TANG/Tang/Util/MonotonicMultiMap.cs new file mode 100644 index 0000000..50d4c6a --- /dev/null +++ b/lang/cs/Source/TANG/Tang/Util/MonotonicMultiMap.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.Collections.Generic; + +namespace Org.Apache.Reef.Tang.Util +{ + public class MonotonicMultiMap<K, V> : AbstractMonotonicMultiMap<K, V> + { + public MonotonicMultiMap() : base(new MonotonicTreeMap<K, ISet<V>>()) + { + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Util/MonotonicSet.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/TANG/Tang/Util/MonotonicSet.cs b/lang/cs/Source/TANG/Tang/Util/MonotonicSet.cs new file mode 100644 index 0000000..2d52d0f --- /dev/null +++ b/lang/cs/Source/TANG/Tang/Util/MonotonicSet.cs @@ -0,0 +1,106 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +using System; +using System.Collections.Generic; +using Org.Apache.Reef.Utilities.Logging; + +namespace Org.Apache.Reef.Tang.Util +{ + public class MonotonicSet<T> : SortedSet<T> + { + private static readonly Logger LOGGER = Logger.GetLogger(typeof(MonotonicSet<T>)); + + //private static readonly long serialVersionUID = 1L; + public MonotonicSet() : base() + { + } + + //public MonotonicSet(SortedSet<T> c) : base(c.Comparer) + //{ + // AddAll(c); + //} + + public MonotonicSet(ICollection<T> c) + : base(c) + { + } + + public MonotonicSet(IComparer<T> c) + : base(c) + { + } + + public new bool Add(T e) //TODO + { + if (this.Contains(e)) + { + Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException("Attempt to re-add " + e + + " to MonotonicSet!"), LOGGER); + } + return base.Add(e); + } + + public bool AddAll(ICollection<T> c) + { + foreach (T t in c) + { + this.Add(t); + } + return c.Count != 0; + } + + public bool ContainsAll(ICollection<T> c) + { + foreach (T t in c) + { + if (!this.Contains(t)) + { + return false; + } + } + return true; + } + + public bool AddAllIgnoreDuplicates(ICollection<T> c) + { + bool ret = false; + foreach (T t in c) + { + if (!Contains(t)) + { + Add(t); + ret = true; + } + } + return ret; + } + + public override void Clear() + { + Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new NotSupportedException("Attempt to clear MonotonicSet!"), LOGGER); + } + + public bool Remove(Object o) + { + Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new NotSupportedException("Attempt to remove " + o + + " from MonotonicSet!"), LOGGER); + return false; + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Util/MonotonicTreeMap.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/TANG/Tang/Util/MonotonicTreeMap.cs b/lang/cs/Source/TANG/Tang/Util/MonotonicTreeMap.cs new file mode 100644 index 0000000..623f249 --- /dev/null +++ b/lang/cs/Source/TANG/Tang/Util/MonotonicTreeMap.cs @@ -0,0 +1,68 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +using System; +using System.Collections.Generic; +using System.Threading; +using Org.Apache.Reef.Utilities.Logging; + +namespace Org.Apache.Reef.Tang.Util +{ + public class MonotonicTreeMap<TKey, TVal> : SortedDictionary<TKey, TVal> + { + private readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); + + private static readonly Logger LOGGER = Logger.GetLogger(typeof(MonotonicTreeMap<TKey, TVal>)); + + public new void Add(TKey key, TVal value) + { + _lock.EnterWriteLock(); + try + { + TVal val; + if (base.TryGetValue(key, out val)) + { + var ex = new ArgumentException("Attempt to re-add: [" + key + + "]\n old value: " + val + " new value " + value); + Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); + } + else + { + base.Add(key, value); + } + } + finally + { + if (_lock.IsWriteLockHeld) + { + _lock.ExitWriteLock(); + } + } + } + + public new void Clear() //TODO + { + throw new NotSupportedException(); + } + + public new void Remove(TKey key) //TODO + { + throw new NotSupportedException(); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Util/ReflectionUtilities.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/TANG/Tang/Util/ReflectionUtilities.cs b/lang/cs/Source/TANG/Tang/Util/ReflectionUtilities.cs new file mode 100644 index 0000000..fec364d --- /dev/null +++ b/lang/cs/Source/TANG/Tang/Util/ReflectionUtilities.cs @@ -0,0 +1,594 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Reflection; +using System.Runtime.CompilerServices; +using Org.Apache.Reef.Utilities.Logging; +using Org.Apache.Reef.Tang.Annotations; +using Org.Apache.Reef.Tang.Exceptions; + +namespace Org.Apache.Reef.Tang.Util +{ + public class ReflectionUtilities + { + private static readonly Logger LOGGER = Logger.GetLogger(typeof(ReflectionUtilities)); + + public static readonly string Regexp = "[\\.\\+]"; + + /// <summary> + /// Gets the AssemblyQualifiedName from the Type. This name is used in ClassHierarchy + /// as a key when add a node as a child to parent. THe name is used as FullName in a Node + /// </summary> + /// <param name="name">The name.</param> + /// <returns></returns> + /// <exception cref="System.ArgumentException">null is passed in FullName() in ReflectionUtilities</exception> + public static string GetAssemblyQualifiedName(Type name) + { + if (name == null) + { + Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException("null is passed in FullName() in ReflectionUtilities"), LOGGER); + } + + Type t = EnsureInterfaceType(name); + + if (t.AssemblyQualifiedName == null && t.Name == null && t.FullName == null) + { + LOGGER.Log(Level.Warning, "The type's name is null: " + t.ToString()); + } + + if (t.AssemblyQualifiedName == null && t.Name != null) + { + return t.Name; + } + + return t.AssemblyQualifiedName; + } + + /// <summary> + /// It returns Type.FullName. This name is used as Name in a Node. + /// It is not unique for a generic type with different type of arguments. + /// It is used for toString or debug info as AssemblyQualifiedName is really long + /// </summary> + /// <param name="name">The name.</param> + /// <returns></returns> + public static string GetName(Type name) + { + if (name.FullName != null) + { + return name.FullName; + } + + //The following lines should be not reached by C# syntax definition. However, it happens for some generic type such as AbstractObserver<T> + //It results in name as null. When null name in the class node gets deserialzed, as name is required filed in class hierarchy proto buffer schame, + //it causes exception during deserialization. The code below is to use first portion of AssemblyQualifiedName for the name of the node node in case type.name is null. + string[] parts = GetAssemblyQualifiedName(name).Split(','); + return parts[0]; + } + + /// <summary> + /// Gets the interface target. + // Foo<T> , given Foo<T> and Foo return T + // example class Foo : Bar<U>, Bas<T> + // iface: Bar, type: Foo, return U + // iface: Bas, type: Foo, return T + // class ACons implements IExternalConstructor<A> + // iface: IExternalConstructor<>, type: ACons return A + /// </summary> + /// <param name="iface">The iface.</param> + /// <param name="type">The type.</param> + /// <returns></returns> + public static Type GetInterfaceTarget(Type iface, Type type) + { + foreach (Type t in ReflectionUtilities.ClassAndAncestors(type)) + { + if (IsGenericTypeof(iface, t)) + { + return t.GetGenericArguments()[0]; //verify it + } + } + return null; + } + + public static Type GetInterfaceTargetForType(Type iface, Type type) + { + if (IsGenericTypeof(iface, type)) + { + return type.GetGenericArguments()[0]; //verify it + } + return null; + } + + /// <summary> + /// Determines whether [is generic typeof] [the specified iface]. + /// </summary> + /// <param name="iface">The iface.</param> + /// <param name="type">The type.</param> + /// <returns> + /// <c>true</c> if [is generic typeof] [the specified iface]; otherwise, <c>false</c>. + /// </returns> + /// <exception cref="System.ApplicationException"></exception> + public static bool IsGenericTypeof(Type iface, Type type) + { + if (iface == null || type == null) + { + var ex = new ApplicationException(string.Format(CultureInfo.CurrentCulture, + "The type passed in IsGenericTypeof is null: iface : {0} type: {1}. ", + iface, type)); + Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); + } + if (type.IsGenericType) + { + if (GetAssemblyQualifiedName(iface).Equals(GetAssemblyQualifiedNameForGeneric(type))) + { + return true; + } + } + return false; + } + + /// <summary> + /// Classes the and ancestors. + /// </summary> + /// <param name="c">The c.</param> + /// <returns></returns> + public static IEnumerable<Type> ClassAndAncestors(Type c) + { + List<Type> workQueue = new List<Type>(); + workQueue.Add(c); //including itself + + foreach (Type t in c.GetInterfaces()) + { + workQueue.Add(t); + } + + Type b = c.BaseType; + while (b != null) + { + workQueue.Add(b); + b = b.BaseType; + } + + if (c.IsInterface) + { + workQueue.Add(typeof (object)); + } + + return workQueue; + } + + public static IEnumerable<Type> ClassAndAncestorsExcludeSelf(Type c) + { + List<Type> workQueue = new List<Type>(); + //workQueue.Add(c); //including itself + + foreach (Type t in c.GetInterfaces()) + { + workQueue.Add(t); + } + + Type b = c.BaseType; + while (b != null) + { + workQueue.Add(b); + b = b.BaseType; + } + + if (c.IsInterface) + { + workQueue.Add(typeof(object)); + } + + return workQueue; + } + + /// <summary> + /// Boxes the class. + /// </summary> + /// <param name="c">The c.</param> + /// <returns></returns> + /// <exception cref="System.NotSupportedException">Encountered unknown primitive type!</exception> + public static Type BoxClass(Type c) + { + if (c.IsPrimitive && c != typeof (Type)) + { + if (c == typeof (bool)) + { + return typeof (Boolean); + } + else if (c == typeof (byte)) + { + return typeof (Byte); + } + else if (c == typeof (char)) + { + return typeof (Char); + } + else if (c == typeof (short)) + { + return typeof (Int16); + } + else if (c == typeof (int)) + { + return typeof (Int32); + } + else if (c == typeof (long)) + { + return typeof (Int64); + } + else if (c == typeof (float)) + { + return typeof (Single); + } + else if (c == typeof (double)) + { + return typeof (Double); + } + else + { + Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new NotSupportedException( + "Encountered unknown primitive type!"), LOGGER); + return c; + } + } + else + { + return c; + } + } + + /// <summary> + /// Determines whether the specified to is coercable. + // public static boolean isCoercable(Class<?> to, Class<?> from) castable from to both are numbers and from has a few bits or subclass relationship + /// </summary> + /// <param name="to">To.</param> + /// <param name="from">From.</param> + /// <returns> + /// <c>true</c> if the specified to is coercable; otherwise, <c>false</c>. + /// </returns> + public static bool IsCoercable(Type to, Type from) + { + to = BoxClass(to); + from = BoxClass(from); + //TODO + //if (Number.class.isAssignableFrom(to) + // && Number.class.isAssignableFrom(from)) { + //return sizeof.get(from) <= sizeof.get(to); + return to.IsAssignableFrom(from); + //return IsAssignableFromIgnoreGeneric(to, from); + } + + /// <summary> + /// Determines whether [is assignable from ignore generic] [the specified to]. + /// </summary> + /// <param name="to">To.</param> + /// <param name="from">From.</param> + /// <returns> + /// <c>true</c> if [is assignable from ignore generic] [the specified to]; otherwise, <c>false</c>. + /// </returns> + public static bool IsAssignableFromIgnoreGeneric(Type to, Type from) + { + var f = ClassAndAncestors(from); + foreach (Type t in f) + { + if (GetAssemblyQualifiedName(to).Equals(GetAssemblyQualifiedNameForGeneric(t))) + { + return true; + } + } + return false; + } + + /// <summary> + /// Ensures the type of the interface. For generic types, full name could be null. In this case, we need to + /// get GetGenericTypeDefinition for the type so that to rerain all teh type information + /// </summary> + /// <param name="interf">The interf.</param> + /// <returns></returns> + public static Type EnsureInterfaceType(Type interf) + { + if (interf != null && interf.IsGenericType && null == interf.FullName) + { + return interf.GetGenericTypeDefinition(); //this is to test if this line is ever reached + } + return interf; + } + + /// <summary> + /// Gets the assembly qualified name for generic. + /// </summary> + /// <param name="t">The t.</param> + /// <returns></returns> + public static string GetAssemblyQualifiedNameForGeneric(Type t) + { + Type t1 = t; + if (t.IsGenericType) + { + t1 = t.GetGenericTypeDefinition(); + } + return t1.AssemblyQualifiedName; + } + + /// <summary> + /// Determines whether [is instance of generic] [the specified p]. + /// </summary> + /// <param name="p">The p.</param> + /// <param name="t">The t.</param> + /// <returns> + /// <c>true</c> if [is instance of generic] [the specified p]; otherwise, <c>false</c>. + /// </returns> + public static bool IsInstanceOfGeneric(object p, Type t) + { + foreach (var g in ReflectionUtilities.ClassAndAncestors(p.GetType())) + { + if (GetAssemblyQualifiedNameForGeneric(t).Equals(GetAssemblyQualifiedNameForGeneric(g))) + { + return true; + } + } + return false; + } + + /// <summary> + /// Gets the name of the type by. + /// </summary> + /// <param name="name">The name.</param> + /// <returns></returns> + /// <exception cref="System.ApplicationException">Not able to get Type from the name provided: + name</exception> + public static Type GetTypeByName(string name) + { + Type t = null; + + t = Type.GetType(name); + + if (t == null) + { + foreach (var a in AppDomain.CurrentDomain.GetAssemblies()) + { + t = a.GetType(name); + if (t != null) + break; + } + } + if (t == null) + { + Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ApplicationException("Not able to get Type from the name provided: " + name), LOGGER); + } + + return t; + } + + /// <summary> + /// Gets the enclosing classes. + /// </summary> + /// <param name="t">The t.</param> + /// <returns></returns> + public static Type[] GetEnclosingClasses(Type t) + { + IList<Type> l = new List<Type>(); + l.Add(t); + Type current = t.DeclaringType; + while (current != null) + { + l.Add(current); + current = current.DeclaringType; + } + return l.Reverse().ToArray(); + } + + /// <summary> + /// Gets the enclosing class names. + /// </summary> + /// <param name="t">The t.</param> + /// <returns></returns> + /// <exception cref="System.ApplicationException">The Type passed to GetEnclosingClassShortNames is null</exception> + public static string[] GetEnclosingClassNames(Type t) + { + if (t == null) + { + Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ApplicationException("The Type passed to GetEnclosingClassShortNames is null"), LOGGER); + } + Type[] ts = GetEnclosingClasses(t); + string[] result = new string[ts.Length]; + for (int i = 0; i < ts.Length; i++) + { + result[i] = GetAssemblyQualifiedName(ts[i]); + } + + return result; + } + + /// <summary> + /// Gets the enclosing class names. + /// </summary> + /// <param name="fullName">The full name.</param> + /// <returns></returns> + /// <exception cref="System.ApplicationException">The name passed to GetEnclosingClassShortNames is null</exception> + public static string[] GetEnclosingClassNames(string fullName) + { + if (fullName == null) + { + Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ApplicationException("The name passed to GetEnclosingClassShortNames is null"), LOGGER); + } + Type t = ReflectionUtilities.GetTypeByName(fullName); + return GetEnclosingClassNames(t); + } + + /// <summary> + /// Gets the named parameter target or null. + /// </summary> + /// <param name="type">The type.</param> + /// <returns></returns> + /// <exception cref="ClassHierarchyException">Named parameter + GetName(type) + implements + /// + multiple interfaces. It is only allowed to implement Name</exception> + public static Type GetNamedParameterTargetOrNull(Type type) + { + var npAnnotation = type.GetCustomAttribute<NamedParameterAttribute>(); + if (npAnnotation != null) + { + Type[] intfs = type.GetInterfaces(); + if (intfs.Length > 1) + { + var ex = new ClassHierarchyException("Named parameter " + GetName(type) + " implements " + + "multiple interfaces. It is only allowed to implement Name<T>"); + Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); + + } + else if (intfs.Length == 0 || !IsName(intfs[0])) + { + var ex = new ClassHierarchyException("Found illegal [NamedParameter " + GetName(type) + + " does not implement Name<T>"); + Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); + } + Type[] args = intfs[0].GetGenericArguments(); + if (args.Length > 1) + { + var ex = new ClassHierarchyException("Found illegal [NamedParameter " + GetName(type) + + " that has more than one arguments"); + Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); + } + if (args.Length == 0) + { + var ex = new ClassHierarchyException("Found illegal [NamedParameter " + GetName(type) + + " that has no argument"); + Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); + } + if (HasConstructor(type) || HasInjectableConstructor(type)) + { + var ex = new ClassHierarchyException("Named parameter " + GetName(type) + " has " + + (HasInjectableConstructor(type) ? "an injectable" : "a") + " constructor. " + + " Named parameters must not declare any constructors."); + Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); + } + + return args[0]; + } + + if (ImplementName(type)) //Implement Name<> but no [NamedParameter] attribute + { + var ex = new ClassHierarchyException("Named parameter " + GetName(type) + + " is missing its [NamedParameter] attribute."); + Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); + } + return null; + } + + public static IEnumerable<Type> GetInterfaces(Type type, bool includeInherited) + { + if (includeInherited || type.BaseType == null) + return type.GetInterfaces(); + else + return type.GetInterfaces().Except(type.BaseType.GetInterfaces()); + } + + // Here is a more elaborate hack to test for annonymous type: + // http://stackoverflow.com/questions/2483023/how-to-test-if-a-type-is-anonymous + // compiler generated classes are always recreatable and need not additional references to check for. + public static bool IsAnnonymousType(Type type) + { + if (type != null) + { + // HACK: The only way to detect anonymous types right now. + return Attribute.IsDefined(type, typeof(CompilerGeneratedAttribute), false) + && type.IsGenericType && type.Name.Contains("AnonymousType") + && (type.Name.StartsWith("<>", true, CultureInfo.CurrentCulture) || type.Name.StartsWith("VB$", true, CultureInfo.CurrentCulture)) + && (type.Attributes & TypeAttributes.NotPublic) == TypeAttributes.NotPublic; + } + return false; + } + + private static bool ImplementName(Type type) + { + foreach (Type t in type.GetInterfaces()) + { + if (IsName(t)) + { + return true; + } + } + return false; + } + + private static bool IsName(Type t) + { + if (t.IsGenericType) + { + return t.GetGenericTypeDefinition().AssemblyQualifiedName.Equals(typeof (Name<>).AssemblyQualifiedName); + } + return false; + } + + private static bool HasConstructor(Type type) + { + bool hasConstructor = false; + + ConstructorInfo[] constructors = + type.GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); + + if (constructors.Length > 1) + { + hasConstructor = true; + } + + if (constructors.Length == 1) + { + ConstructorInfo c = constructors[0]; + ParameterInfo[] p = c.GetParameters(); + if (p.Length > 1) + { + // Multiple args. Definitely not implicit. + hasConstructor = true; + } + else if (p.Length == 1) + { + // One arg. Could be an inner class, in which case the compiler + // included an implicit one parameter constructor that takes the + // enclosing type. + if (p[0].ParameterType != type.DeclaringType) + { + hasConstructor = true; + } + } + } + return hasConstructor; + } + + private static bool HasInjectableConstructor(Type type) + { + bool isInjectable = false; + + ConstructorInfo[] constructors = + type.GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); + + foreach (ConstructorInfo c in constructors) + { + foreach (Attribute a in c.GetCustomAttributes()) + { + if (a is InjectAttribute) + { + isInjectable = true; + } + } + } + return isInjectable; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/Util/SetValuedKey.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/TANG/Tang/Util/SetValuedKey.cs b/lang/cs/Source/TANG/Tang/Util/SetValuedKey.cs new file mode 100644 index 0000000..4c3090e --- /dev/null +++ b/lang/cs/Source/TANG/Tang/Util/SetValuedKey.cs @@ -0,0 +1,62 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Org.Apache.Reef.Tang.Util +{ + class SetValuedKey + { + public IList<object> key; + + public SetValuedKey(object[] ts, object[] us) + { + key = ts.ToList<object>(); + foreach (var o in us) + { + key.Add(o); + } + } + + public override int GetHashCode() + { + int i = 0; + foreach (object t in key) + { + i += t.GetHashCode(); + } + return i; + } + + public override bool Equals(Object o) + { + SetValuedKey other = (SetValuedKey)o; + if (other.key.Count != this.key.Count) { return false; } + for (int i = 0; i < this.key.Count; i++) + { + if (this.key[i].Equals(other.key[i])) + { + return false; + } + } + return true; + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/TANG/Tang/packages.config ---------------------------------------------------------------------- diff --git a/lang/cs/Source/TANG/Tang/packages.config b/lang/cs/Source/TANG/Tang/packages.config new file mode 100644 index 0000000..933b7e1 --- /dev/null +++ b/lang/cs/Source/TANG/Tang/packages.config @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> +<packages> + <package id="Microsoft.Hadoop.Avro" version="1.4.0.0" targetFramework="net45" /> + <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" /> + <package id="protobuf-net" version="2.0.0.668" targetFramework="net45" /> +</packages> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Tools/ClassHierarchyBuilder/ClassHierarchyBuilder.csproj ---------------------------------------------------------------------- diff --git a/lang/cs/Source/Tools/ClassHierarchyBuilder/ClassHierarchyBuilder.csproj b/lang/cs/Source/Tools/ClassHierarchyBuilder/ClassHierarchyBuilder.csproj new file mode 100644 index 0000000..c3ddf65 --- /dev/null +++ b/lang/cs/Source/Tools/ClassHierarchyBuilder/ClassHierarchyBuilder.csproj @@ -0,0 +1,90 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{34A9CD98-0D15-4CA0-AEA5-E53593A31047}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Org.Apache.Reef.Tools.ClassHierarchyBuilder</RootNamespace> + <AssemblyName>Org.Apache.Reef.Tools.ClassHierarchyBuilder</AssemblyName> + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\..\..\bin\Debug\Org.Apache.Reef.Tools.ClassHierarchyBuilder\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>..\..\..\bin\Release\Microsoft.Reef.Tools.ClassHierarchyBuilder</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup> + <StartupObject /> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\REEF\reef-common\ReefCommon\ReefCommon.csproj"> + <Project>{545a0582-4105-44ce-b99c-b1379514a630}</Project> + <Name>ReefCommon</Name> + </ProjectReference> + <ProjectReference Include="..\..\REEF\reef-tasks\Tasks\Tasks.csproj"> + <Project>{75503f90-7b82-4762-9997-94b5c68f15db}</Project> + <Name>Tasks</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tang\Tang\Tang.csproj"> + <Project>{97dbb573-3994-417a-9f69-ffa25f00d2a6}</Project> + <Name>Tang</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Tools/ClassHierarchyBuilder/Program.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/Tools/ClassHierarchyBuilder/Program.cs b/lang/cs/Source/Tools/ClassHierarchyBuilder/Program.cs new file mode 100644 index 0000000..32a85d0 --- /dev/null +++ b/lang/cs/Source/Tools/ClassHierarchyBuilder/Program.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 Org.Apache.Reef.Tasks; +using Org.Apache.Reef.Tang.Implementations; +using Org.Apache.Reef.Tang.Interface; +using Org.Apache.Reef.Tang.Protobuf; +using Org.Apache.Reef.Tang.Types; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; + +namespace Org.Apache.Reef.Tools +{ + public class ClassHierarchyBuilder + { + /// <summary> + /// This program generates class hierarchy bin file for the list of dlls, plus a defalut list + /// The default list include: ITask, StreamTask1, HelloTask and ShellTask, please remove if not needed + /// </summary> + /// <param name="args"> additional dlls needed to build class hierarchy </param> + public static void Main(string[] args) + { + const string DllSubfix = ".dll"; + const string ClassHierarchyBinFileName = "task.bin"; + + List<string> taskDlls = new List<string>(); + + foreach (string arg in args) + { + string assemblyName = arg; + if (!arg.EndsWith(DllSubfix, StringComparison.OrdinalIgnoreCase)) + { + assemblyName += DllSubfix; + } + if (!File.Exists(assemblyName)) + { + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "invalid argument: assembly {0} cannot be found", assemblyName)); + } + taskDlls.Add(arg); + } + + taskDlls.Add(GetAssemblyName(typeof(ITask))); + taskDlls.Add(GetAssemblyName(typeof(HelloTask))); + taskDlls.Add(GetAssemblyName(typeof(ShellTask))); + taskDlls.Add(GetAssemblyName(typeof(StreamTask1))); + + IClassHierarchy ns = TangFactory.GetTang().GetClassHierarchy(taskDlls.ToArray()); + + // the following is verification only + // to verify that a class indeeded has been added to the class hierarchy, check the class name + IClassNode streamTaskClassNode = (IClassNode)ns.GetNode(typeof(StreamTask1).AssemblyQualifiedName); + IClassNode helloTaskClassNode = (IClassNode)ns.GetNode(typeof(HelloTask).AssemblyQualifiedName); + IClassNode shellTaskClassNode = (IClassNode)ns.GetNode(typeof(ShellTask).AssemblyQualifiedName); + + ProtocolBufferClassHierarchy.Serialize(ClassHierarchyBinFileName, ns); + IClassHierarchy ch = ProtocolBufferClassHierarchy.DeSerialize(ClassHierarchyBinFileName); + + IClassNode retrievedStreamTaskClassNode = (IClassNode)ch.GetNode(typeof(StreamTask1).AssemblyQualifiedName); + IClassNode retrievedHelloTaskClassNode = (IClassNode)ch.GetNode(typeof(HelloTask).AssemblyQualifiedName); + IClassNode retrievedShellTaskClassNode = (IClassNode)ch.GetNode(typeof(ShellTask).AssemblyQualifiedName); + + if (!streamTaskClassNode.GetFullName().Equals(retrievedStreamTaskClassNode.GetFullName()) || + !helloTaskClassNode.GetFullName().Equals(retrievedHelloTaskClassNode.GetFullName()) || + !shellTaskClassNode.GetFullName().Equals(retrievedShellTaskClassNode.GetFullName())) + { + Console.WriteLine("Node deseriliazed is not equal"); + } + else + { + Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "Class hierarchy written to [{0}].", Directory.GetCurrentDirectory())); + } + } + + private static string GetAssemblyName(Type type) + { + return type.Assembly.GetName().Name; + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Tools/ClassHierarchyBuilder/Properties/AssemblyInfo.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/Tools/ClassHierarchyBuilder/Properties/AssemblyInfo.cs b/lang/cs/Source/Tools/ClassHierarchyBuilder/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..02de849 --- /dev/null +++ b/lang/cs/Source/Tools/ClassHierarchyBuilder/Properties/AssemblyInfo.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 System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ClassHierarchyBuilder")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ClassHierarchyBuilder")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("8a034f16-c6c7-497a-b3c0-f8cfea1635e9")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Tools/ReefAll/Properties/AssemblyInfo.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/Tools/ReefAll/Properties/AssemblyInfo.cs b/lang/cs/Source/Tools/ReefAll/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2fb7d69 --- /dev/null +++ b/lang/cs/Source/Tools/ReefAll/Properties/AssemblyInfo.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 System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ReefAll")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ReefAll")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("def59cbf-1539-414c-a518-486d1553077c")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Tools/ReefAll/ReefAll.csproj ---------------------------------------------------------------------- diff --git a/lang/cs/Source/Tools/ReefAll/ReefAll.csproj b/lang/cs/Source/Tools/ReefAll/ReefAll.csproj new file mode 100644 index 0000000..4f60fe6 --- /dev/null +++ b/lang/cs/Source/Tools/ReefAll/ReefAll.csproj @@ -0,0 +1,102 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{4C137C79-3A28-47D2-BFB9-A3CAB1EEDACE}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Org.Apache.Reef.All</RootNamespace> + <AssemblyName>Org.Apache.Reef.All</AssemblyName> + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\..\..\bin\Debug\Org.Apache.Reef.All\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>..\..\..\bin\Release\Microsoft.Reef.All\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\REEF\reef-applications\Evaluator\Evaluator.csproj"> + <Project>{1b983182-9c30-464c-948d-f87eb93a8240}</Project> + <Name>Evaluator</Name> + </ProjectReference> + <ProjectReference Include="..\..\REEF\reef-common\ReefCommon\ReefCommon.csproj"> + <Project>{545a0582-4105-44ce-b99c-b1379514a630}</Project> + <Name>ReefCommon</Name> + </ProjectReference> + <ProjectReference Include="..\..\REEF\reef-common\ReefDriver\ReefDriver.csproj"> + <Project>{a6baa2a7-f52f-4329-884e-1bcf711d6805}</Project> + <Name>ReefDriver</Name> + </ProjectReference> + <ProjectReference Include="..\..\REEF\reef-io\NetWork\NetWork.csproj"> + <Project>{883ce800-6a6a-4e0a-b7fe-c054f4f2c1dc}</Project> + <Name>NetWork</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tang\Tang\Tang.csproj"> + <Project>{97dbb573-3994-417a-9f69-ffa25f00d2a6}</Project> + <Name>Tang</Name> + </ProjectReference> + <ProjectReference Include="..\..\Utilities\Utilities.csproj"> + <Project>{79e7f89a-1dfb-45e1-8d43-d71a954aeb98}</Project> + <Name>Utilities</Name> + </ProjectReference> + <ProjectReference Include="..\..\WAKE\Wake\Wake.csproj"> + <Project>{cdfb3464-4041-42b1-9271-83af24cd5008}</Project> + <Name>Wake</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Utilities/AvroUtils.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/Utilities/AvroUtils.cs b/lang/cs/Source/Utilities/AvroUtils.cs new file mode 100644 index 0000000..1db652d --- /dev/null +++ b/lang/cs/Source/Utilities/AvroUtils.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 System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Hadoop.Avro; + +namespace Org.Apache.Reef.Utilities +{ + public class AvroUtils + { + /// <summary> + /// Convert an object to byte array using Avro serializiation + /// </summary> + /// <param name="obj">The object to serialize</param> + /// <returns>The serialized object in a byte array</returns> + public static byte[] AvroSerialize<T>(T obj) + { + IAvroSerializer<T> serializer = AvroSerializer.Create<T>(); + using (MemoryStream stream = new MemoryStream()) + { + serializer.Serialize(stream, obj); + return stream.GetBuffer(); + } + } + + /// <summary> + /// Converts a byte array to an object using Avro deserialization. + /// </summary> + /// <param name="data">The byte array to deserialize</param> + /// <returns>The deserialized object</returns> + public static T AvroDeserialize<T>(byte[] data) + { + IAvroSerializer<T> deserializer = AvroSerializer.Create<T>(); + using (MemoryStream stream = new MemoryStream(data)) + { + return deserializer.Deserialize(stream); + } + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Utilities/ByteUtilities.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/Utilities/ByteUtilities.cs b/lang/cs/Source/Utilities/ByteUtilities.cs new file mode 100644 index 0000000..655e9d2 --- /dev/null +++ b/lang/cs/Source/Utilities/ByteUtilities.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 System; +using System.Text; + +namespace Org.Apache.Reef.Utilities +{ + public class ByteUtilities + { + public static byte[] StringToByteArrays(string s) + { + return Encoding.UTF8.GetBytes(s); + } + + public static string ByteArrarysToString(byte[] b) + { + return Encoding.UTF8.GetString(b); + } + + public static byte[] CopyBytesFrom(byte[] from) + { + int length = Buffer.ByteLength(from); + byte[] to = new byte[length]; + Buffer.BlockCopy(from, 0, to, 0, length); + return to; + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/Utilities/Diagnostics/DiagnosticsMessages.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Source/Utilities/Diagnostics/DiagnosticsMessages.cs b/lang/cs/Source/Utilities/Diagnostics/DiagnosticsMessages.cs new file mode 100644 index 0000000..c0a4d6e --- /dev/null +++ b/lang/cs/Source/Utilities/Diagnostics/DiagnosticsMessages.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 System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Org.Apache.Reef.Utilities.Diagnostics +{ + public class DiagnosticsMessages + { + public const string ExceptionThrowing = "ExceptionThrowing"; + + public const string ExceptionCaught = "ExceptionCaught"; + + public const string DumperTimeout = "DumperTimeout"; + + public const string DumperError = "DumperError"; + + public const string CallingDumper = "CallingDumper"; + + public const string DumperException = "DumperException"; + } +}
