public static Map <QName, XMLEventParser> getDefaultParsers() { ConcurrentHashMap <QName, XMLEventParser> parsers = new ConcurrentHashMap <QName, XMLEventParser>(); String xns = XALConstants.XAL_NAMESPACE; parsers.put(new QName(xns, "Address"), new XALAddress(xns)); parsers.put(new QName(xns, "AddressDetails"), new XALAddressDetails(xns)); parsers.put(new QName(xns, "AddressLine"), new XALAddressLine(xns)); parsers.put(new QName(xns, "AddressLines"), new XALAddressLines(xns)); parsers.put(new QName(xns, "AdministrativeArea"), new XALAdministrativeArea(xns)); parsers.put(new QName(xns, "Country"), new XALCountry(xns)); parsers.put(new QName(xns, "CountryName"), new XALCountryName(xns)); parsers.put(new QName(xns, "CountryNameCode"), new XALCountryNameCode(xns)); parsers.put(new QName(xns, "Locality"), new XALLocality(xns)); parsers.put(new QName(xns, "PostalServiceElements"), new XALPostalServiceElements(xns)); parsers.put(new QName(xns, "Thoroughfare"), new XALThoroughfare(xns)); StringXMLEventParser stringParser = new StringXMLEventParser(); foreach (String s in StringFields) { parsers.put(new QName(xns, s), stringParser); } return(parsers); }
private string getDatabase(string NETConnectionStr) { char[] sp = new char[] { ';' }; string[] segment = NETConnectionStr.Split(sp); // ConcurrentHashMap <string, string> map = new ConcurrentHashMap <string, string>(); foreach (string sg in segment) { char[] sgp = new char[] { '=' }; string[] s = sg.Split(sgp); //无密码时参数就1个长度 if (s.Length == 1) { map.put(s[0].Trim(), ""); } else { map.put(s[0].Trim(), s[1]); } } // database = map.get("database").ToString(); return(database); }
/// <exception cref="Org.Apache.Hadoop.Lib.Server.ServiceException"/> protected internal override void Init() { timersSize = GetServiceConfig().GetInt(ConfTimersSize, 10); counterLock = new ReentrantLock(); timerLock = new ReentrantLock(); variableLock = new ReentrantLock(); samplerLock = new ReentrantLock(); IDictionary <string, InstrumentationService.VariableHolder> jvmVariables = new ConcurrentHashMap <string, InstrumentationService.VariableHolder>(); counters = new ConcurrentHashMap <string, IDictionary <string, AtomicLong> >(); timers = new ConcurrentHashMap <string, IDictionary <string, InstrumentationService.Timer > >(); variables = new ConcurrentHashMap <string, IDictionary <string, InstrumentationService.VariableHolder > >(); samplers = new ConcurrentHashMap <string, IDictionary <string, InstrumentationService.Sampler > >(); samplersList = new AList <InstrumentationService.Sampler>(); all = new LinkedHashMap <string, IDictionary <string, object> >(); all["os-env"] = Sharpen.Runtime.GetEnv(); all["sys-props"] = (IDictionary <string, object>)(IDictionary) Runtime.GetProperties (); all["jvm"] = jvmVariables; all["counters"] = (IDictionary)counters; all["timers"] = (IDictionary)timers; all["variables"] = (IDictionary)variables; all["samplers"] = (IDictionary)samplers; jvmVariables["free.memory"] = new InstrumentationService.VariableHolder <long>(new _Variable_87()); jvmVariables["max.memory"] = new InstrumentationService.VariableHolder <long>(new _Variable_93()); jvmVariables["total.memory"] = new InstrumentationService.VariableHolder <long>(new _Variable_99()); }
public virtual void TestRMNMInfoMissmatch() { RMContext rmc = Org.Mockito.Mockito.Mock <RMContext>(); ResourceScheduler rms = Org.Mockito.Mockito.Mock <ResourceScheduler>(); ConcurrentMap <NodeId, RMNode> map = new ConcurrentHashMap <NodeId, RMNode>(); RMNode node = MockNodes.NewNodeInfo(1, MockNodes.NewResource(4 * 1024)); map[node.GetNodeID()] = node; Org.Mockito.Mockito.When(rmc.GetRMNodes()).ThenReturn(map); RMNMInfo rmInfo = new RMNMInfo(rmc, rms); string liveNMs = rmInfo.GetLiveNodeManagers(); ObjectMapper mapper = new ObjectMapper(); JsonNode jn = mapper.ReadTree(liveNMs); NUnit.Framework.Assert.AreEqual("Unexpected number of live nodes:", 1, jn.Size()); IEnumerator <JsonNode> it = jn.GetEnumerator(); while (it.HasNext()) { JsonNode n = it.Next(); NUnit.Framework.Assert.IsNotNull(n.Get("HostName")); NUnit.Framework.Assert.IsNotNull(n.Get("Rack")); NUnit.Framework.Assert.IsTrue("Node " + n.Get("NodeId") + " should be RUNNING", n .Get("State").AsText().Contains("RUNNING")); NUnit.Framework.Assert.IsNotNull(n.Get("NodeHTTPAddress")); NUnit.Framework.Assert.IsNotNull(n.Get("LastHealthUpdate")); NUnit.Framework.Assert.IsNotNull(n.Get("HealthReport")); NUnit.Framework.Assert.IsNotNull(n.Get("NodeManagerVersion")); NUnit.Framework.Assert.IsNull(n.Get("NumContainers")); NUnit.Framework.Assert.IsNull(n.Get("UsedMemoryMB")); NUnit.Framework.Assert.IsNull(n.Get("AvailableMemoryMB")); } }
public NMTokenSecretManagerInRM(Configuration conf) { this.conf = conf; timer = new Timer(); rollingInterval = this.conf.GetLong(YarnConfiguration.RmNmtokenMasterKeyRollingIntervalSecs , YarnConfiguration.DefaultRmNmtokenMasterKeyRollingIntervalSecs) * 1000; // Add an activation delay. This is to address the following race: RM may // roll over master-key, scheduling may happen at some point of time, an // NMToken created with a password generated off new master key, but NM // might not have come again to RM to update the shared secret: so AM has a // valid password generated off new secret but NM doesn't know about the // secret yet. // Adding delay = 1.5 * expiry interval makes sure that all active NMs get // the updated shared-key. this.activationDelay = (long)(conf.GetLong(YarnConfiguration.RmNmExpiryIntervalMs , YarnConfiguration.DefaultRmNmExpiryIntervalMs) * 1.5); Log.Info("NMTokenKeyRollingInterval: " + this.rollingInterval + "ms and NMTokenKeyActivationDelay: " + this.activationDelay + "ms"); if (rollingInterval <= activationDelay * 2) { throw new ArgumentException(YarnConfiguration.RmNmtokenMasterKeyRollingIntervalSecs + " should be more than 3 X " + YarnConfiguration.RmNmExpiryIntervalMs); } appAttemptToNodeKeyMap = new ConcurrentHashMap <ApplicationAttemptId, HashSet <NodeId > >(); }
internal LocalResourcesTrackerImpl(string user, ApplicationId appId, Dispatcher dispatcher , ConcurrentMap <LocalResourceRequest, LocalizedResource> localrsrc, bool useLocalCacheDirectoryManager , Configuration conf, NMStateStoreService stateStore) { /* * This flag controls whether this resource tracker uses hierarchical * directories or not. For PRIVATE and PUBLIC resource trackers it * will be set whereas for APPLICATION resource tracker it would * be false. */ /* * It is used to keep track of resource into hierarchical directory * while it is getting downloaded. It is useful for reference counting * in case resource localization fails. */ /* * starting with 10 to accommodate 0-9 directories created as a part of * LocalCacheDirectoryManager. So there will be one unique number generator * per APPLICATION, USER and PUBLIC cache. */ this.appId = appId; this.user = user; this.dispatcher = dispatcher; this.localrsrc = localrsrc; this.useLocalCacheDirectoryManager = useLocalCacheDirectoryManager; if (this.useLocalCacheDirectoryManager) { directoryManagers = new ConcurrentHashMap <Path, LocalCacheDirectoryManager>(); inProgressLocalResourcesMap = new ConcurrentHashMap <LocalResourceRequest, Path>(); } this.conf = conf; this.stateStore = stateStore; }
private T GetToAdd <T>(string group, string name, Lock Lock, IDictionary <string, IDictionary <string, T> > map) { System.Type klass = typeof(T); bool locked = false; try { IDictionary <string, T> groupMap = map[group]; if (groupMap == null) { Lock.Lock(); locked = true; groupMap = map[group]; if (groupMap == null) { groupMap = new ConcurrentHashMap <string, T>(); map[group] = groupMap; } } T element = groupMap[name]; if (element == null) { if (!locked) { Lock.Lock(); locked = true; } element = groupMap[name]; if (element == null) { try { if (klass == typeof(InstrumentationService.Timer)) { element = (T) new InstrumentationService.Timer(timersSize); } else { element = System.Activator.CreateInstance(klass); } } catch (Exception ex) { throw new RuntimeException(ex); } groupMap[name] = element; } } return(element); } finally { if (locked) { Lock.Unlock(); } } }
/// <summary>Constructor.</summary> /// <param name="initialCapacity"/> public ConcurrentHashIndex(int initialCapacity) { item2Index = new ConcurrentHashMap <E, int>(initialCapacity); indexSize = 0; Lock = new ReentrantLock(); object[] arr = new object[initialCapacity]; index2Item = new AtomicReference <object[]>(arr); }
public override void AddPatterns(string sentId, IDictionary <int, ICollection <E> > patterns) { if (!patternsForEachToken.Contains(sentId)) { patternsForEachToken[sentId] = new ConcurrentHashMap <int, ICollection <Pattern> >(); } patternsForEachToken[sentId].PutAll(patterns); }
public void TestGet() { ConcurrentHashMap<Object, Object> map = map5(); Assert.AreEqual("A", (String)map.Get(one)); ConcurrentHashMap<Object, Object> empty = new ConcurrentHashMap<Object, Object>(); Assert.IsNull(map.Get("anything")); Assert.IsNull(empty.Get("anything")); }
/// <exception cref="System.IO.IOException"/> /// <exception cref="Sharpen.URISyntaxException"/> /// <exception cref="System.Exception"/> /// <exception cref="Sharpen.ExecutionException"/> public virtual void TestDownloadPublicWithStatCache() { Configuration conf = new Configuration(); FileContext files = FileContext.GetLocalFSFileContext(conf); Path basedir = files.MakeQualified(new Path("target", typeof(TestFSDownload).Name )); // if test directory doesn't have ancestor permission, skip this test FileSystem f = basedir.GetFileSystem(conf); Assume.AssumeTrue(FSDownload.AncestorsHaveExecutePermissions(f, basedir, null)); files.Mkdir(basedir, null, true); conf.SetStrings(typeof(TestFSDownload).FullName, basedir.ToString()); int size = 512; ConcurrentMap <Path, AtomicInteger> counts = new ConcurrentHashMap <Path, AtomicInteger >(); CacheLoader <Path, Future <FileStatus> > loader = FSDownload.CreateStatusCacheLoader (conf); LoadingCache <Path, Future <FileStatus> > statCache = CacheBuilder.NewBuilder().Build (new _CacheLoader_328(counts, loader)); // increment the count // use the default loader // test FSDownload.isPublic() concurrently int fileCount = 3; IList <Callable <bool> > tasks = new AList <Callable <bool> >(); for (int i = 0; i < fileCount; i++) { Random rand = new Random(); long sharedSeed = rand.NextLong(); rand.SetSeed(sharedSeed); System.Console.Out.WriteLine("SEED: " + sharedSeed); Path path = new Path(basedir, "test-file-" + i); CreateFile(files, path, size, rand); FileSystem fs = path.GetFileSystem(conf); FileStatus sStat = fs.GetFileStatus(path); tasks.AddItem(new _Callable_358(fs, path, sStat, statCache)); } ExecutorService exec = Executors.NewFixedThreadPool(fileCount); try { IList <Future <bool> > futures = exec.InvokeAll(tasks); // files should be public foreach (Future <bool> future in futures) { NUnit.Framework.Assert.IsTrue(future.Get()); } // for each path exactly one file status call should be made foreach (AtomicInteger count in counts.Values) { NUnit.Framework.Assert.AreSame(count.Get(), 1); } } finally { exec.Shutdown(); } }
public RepositoryCache() { cacheMap = new ConcurrentHashMap<RepositoryCache.Key, Reference<Repository>>(); openLocks = new RepositoryCache.Lock[4]; for (int i = 0; i < openLocks.Length; i++) { openLocks[i] = new RepositoryCache.Lock(); } }
public RepositoryCache() { cacheMap = new ConcurrentHashMap <RepositoryCache.Key, Reference <Repository> >(); openLocks = new RepositoryCache.Lock[4]; for (int i = 0; i < openLocks.Length; i++) { openLocks[i] = new RepositoryCache.Lock(); } }
public ConcurrentHashMap <string, object> getAutoMatchWaitList() { if (null == _autoMatchWaitList) { _autoMatchWaitList = new ConcurrentHashMap <string, object>(); } return(_autoMatchWaitList); }
/// <summary>Construct a persistent cookie store.</summary> /// <remarks>Construct a persistent cookie store.</remarks> public PersistentCookieStore(Database db) { // Weak reference to a Database. The reason it's weak is because // there's a circular reference, and so the Weakref should avoid // the GC being thwarted. this.dbWeakRef = new WeakReference <Database>(db); cookies = new ConcurrentHashMap(); // Load any previously stored cookies into the store LoadPreviouslyStoredCookies(db); // Clear out expired cookies ClearExpired(new DateTime()); }
private static ConcurrentHashMap<Object, Object> map5() { ConcurrentHashMap<Object, Object> map = new ConcurrentHashMap<Object, Object>(5); Assert.IsTrue(map.IsEmpty()); map.Put(one, "A"); map.Put(two, "B"); map.Put(three, "C"); map.Put(four, "D"); map.Put(five, "E"); Assert.IsFalse(map.IsEmpty()); Assert.AreEqual(5, map.Size()); return map; }
public PatternsForEachTokenInMemory(Properties props, IDictionary <string, IDictionary <int, ICollection <E> > > pats) { ArgumentParser.FillOptions(this, props); //TODO: make this atomic if (patternsForEachToken == null) { patternsForEachToken = new ConcurrentHashMap <string, IDictionary <int, ICollection <Pattern> > >(); } if (pats != null) { AddPatterns(pats); } }
static Log() { // default "catch-all" tag enabledTags = new ConcurrentHashMap <string, int>(); enabledTags.Put(Log.Tag, Warn); enabledTags.Put(Log.TagSync, Warn); enabledTags.Put(Log.TagRemoteRequest, Warn); enabledTags.Put(Log.TagView, Warn); enabledTags.Put(Log.TagQuery, Warn); enabledTags.Put(Log.TagChangeTracker, Warn); enabledTags.Put(Log.TagRouter, Warn); enabledTags.Put(Log.TagDatabase, Warn); enabledTags.Put(Log.TagListener, Warn); enabledTags.Put(Log.TagMultiStreamWriter, Warn); enabledTags.Put(Log.TagBlobStore, Warn); }
public virtual void TestLogFileWithDriveLetter() { ContainerImpl container = Org.Mockito.Mockito.Mock <ContainerImpl>(); ApplicationIdPBImpl appId = Org.Mockito.Mockito.Mock <ApplicationIdPBImpl>(); Org.Mockito.Mockito.When(appId.ToString()).ThenReturn("appId"); Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Application.Application app = Org.Mockito.Mockito.Mock <Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Application.Application >(); Org.Mockito.Mockito.When(app.GetAppId()).ThenReturn(appId); ApplicationAttemptIdPBImpl appAttemptId = Org.Mockito.Mockito.Mock <ApplicationAttemptIdPBImpl >(); Org.Mockito.Mockito.When(appAttemptId.GetApplicationId()).ThenReturn(appId); ConcurrentMap <ApplicationId, Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Application.Application > applications = new ConcurrentHashMap <ApplicationId, Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Application.Application >(); applications[appId] = app; ContainerId containerId = Org.Mockito.Mockito.Mock <ContainerIdPBImpl>(); Org.Mockito.Mockito.When(containerId.ToString()).ThenReturn("containerId"); Org.Mockito.Mockito.When(containerId.GetApplicationAttemptId()).ThenReturn(appAttemptId ); ConcurrentMap <ContainerId, Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Container.Container > containers = new ConcurrentHashMap <ContainerId, Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Container.Container >(); containers[containerId] = container; LocalDirsHandlerService localDirs = Org.Mockito.Mockito.Mock <LocalDirsHandlerService >(); Org.Mockito.Mockito.When(localDirs.GetLogPathToRead("appId" + Path.Separator + "containerId" + Path.Separator + "fileName")).ThenReturn(new Path("F:/nmlogs/appId/containerId/fileName" )); NodeManager.NMContext context = Org.Mockito.Mockito.Mock <NodeManager.NMContext>(); Org.Mockito.Mockito.When(context.GetLocalDirsHandler()).ThenReturn(localDirs); Org.Mockito.Mockito.When(context.GetApplications()).ThenReturn(applications); Org.Mockito.Mockito.When(context.GetContainers()).ThenReturn(containers); FilePath logFile = ContainerLogsUtils.GetContainerLogFile(containerId, "fileName" , null, context); NUnit.Framework.Assert.IsTrue("logFile lost drive letter " + logFile, logFile.ToString ().IndexOf("F:" + FilePath.separator + "nmlogs") > -1); }
public static Map <QName, XMLEventParser> getDefaultParsers() { ConcurrentHashMap <QName, XMLEventParser> parsers = new ConcurrentHashMap <QName, XMLEventParser>(); String ans = AtomConstants.ATOM_NAMESPACE; parsers.put(new QName(ans, "author"), new AtomPerson(ans)); parsers.put(new QName(ans, "link"), new AtomLink(ans)); StringXMLEventParser stringParser = new StringXMLEventParser(); foreach (String s in StringFields) { parsers.put(new QName(ans, s), stringParser); } return(parsers); }
/** * java * "jdbc:mysql://localhost:3306/mysql?user=root&password=12345678" * * .net * server=127.0.0.1;Port=3306; * user id=root; password=NVfaQnXAZJaQJhW7; * database=ultrax; pooling=false;charset=utf8 */ private string convertPathToJDBC(string NETConnectionStr) { char[] sp = new char[] { ';' }; string[] segment = NETConnectionStr.Split(sp); // string JDBCConnectionStr = "jdbc:" + sql + "://"; // ConcurrentHashMap <string, string> map = new ConcurrentHashMap <string, string>(); foreach (string sg in segment) { char[] sgp = new char[] { '=' }; string[] s = sg.Split(sgp); //无密码时参数就1个长度 if (s.Length == 1) { map.put(s[0].Trim(), ""); } else { map.put(s[0].Trim(), s[1]); } } // JDBCConnectionStr += map.get("server"); JDBCConnectionStr += ":" + map.get("Port") + "/"; JDBCConnectionStr += map.get("database") + "?user="******"database").ToString(); JDBCConnectionStr += map.get("user id") + "&password="******"password") + "&charset="; JDBCConnectionStr += map.get("charset"); return(JDBCConnectionStr); }
public static Map <QName, XMLEventParser> getDefaultParsers() { ConcurrentHashMap <QName, XMLEventParser> parsers = new ConcurrentHashMap <QName, XMLEventParser>(); String ns = GXConstants.GX_NAMESPACE; parsers.put(new QName(ns, "AnimatedUpdate"), new GXAnimatedUpdate(ns)); parsers.put(new QName(ns, "FlyTo"), new GXFlyTo(ns)); parsers.put(new QName(ns, "LatLonQuad"), new GXLatLongQuad(ns)); parsers.put(new QName(ns, "Playlist"), new GXPlaylist(ns)); parsers.put(new QName(ns, "SoundCue"), new GXSoundCue(ns)); parsers.put(new QName(ns, "TimeSpan"), new KMLTimeSpan(ns)); parsers.put(new QName(ns, "TimeStamp"), new KMLTimeStamp(ns)); parsers.put(new QName(ns, "Tour"), new GXTour(ns)); parsers.put(new QName(ns, "TourControl"), new GXTourControl(ns)); parsers.put(new QName(ns, "Wait"), new GXWait(ns)); StringXMLEventParser stringParser = new StringXMLEventParser(); foreach (String s in StringFields) { parsers.put(new QName(ns, s), stringParser); } DoubleXMLEventParser doubleParser = new DoubleXMLEventParser(); foreach (String s in DoubleFields) { parsers.put(new QName(ns, s), doubleParser); } BooleanXMLEventParser booleanParser = new BooleanXMLEventParser(); foreach (String s in BooleanFields) { parsers.put(new QName(ns, s), booleanParser); } return(parsers); }
internal virtual LocalResourcesTracker CreateMockTracker(string user, long rsrcSize , long nRsrcs, long timestamp, long tsstep) { Configuration conf = new Configuration(); ConcurrentMap <LocalResourceRequest, LocalizedResource> trackerResources = new ConcurrentHashMap <LocalResourceRequest, LocalizedResource>(); LocalResourcesTracker ret = Org.Mockito.Mockito.Spy(new LocalResourcesTrackerImpl (user, null, null, trackerResources, false, conf, new NMNullStateStoreService()) ); for (int i = 0; i < nRsrcs; ++i) { LocalResourceRequest req = new LocalResourceRequest(new Path("file:///" + user + "/rsrc" + i), timestamp + i * tsstep, LocalResourceType.File, LocalResourceVisibility .Public, null); long ts = timestamp + i * tsstep; Path p = new Path("file:///local/" + user + "/rsrc" + i); LocalizedResource rsrc = new _LocalizedResource_93(rsrcSize, p, ts, req, null); trackerResources[req] = rsrc; } return(ret); }
public BasicXMLEventParserContext(BasicXMLEventParserContext ctx) { this.parsers = ctx.parsers; this.setDefaultNamespaceURI(ctx.getDefaultNamespaceURI()); this.initialize(); }
public override IDictionary <K1, V1> SetMap <K1, V1>(IDictionary <K1, V1> map, int initCapacity) { map = new ConcurrentHashMap <K1, V1>(initCapacity); return(map); }
/// <summary>Default constructor.</summary> /// <remarks>Default constructor.</remarks> public BasicCredentialsProvider() : base() { this.credMap = new ConcurrentHashMap <AuthScope, Credentials>(); }
public void TestIsEmpty() { ConcurrentHashMap<Object, Object> empty = new ConcurrentHashMap<Object, Object>(); ConcurrentHashMap<Object, Object> map = map5(); Assert.IsTrue(empty.IsEmpty()); Assert.IsFalse(map.IsEmpty()); }
/// <summary> /// Default ctor /// </summary> public ConcurrentDictionary(IEqualityComparer <TKey> comparer) { map = new ConcurrentHashMap <TKey, TValue>(); }
/// <summary> /// Creates an Dictionary with the given capacity /// </summary> public ConcurrentDictionary(int capacity) { map = new ConcurrentHashMap <TKey, TValue>(capacity); }
public void TestContainsValue_NullReferenceException() { try { ConcurrentHashMap<Object, Object> c = new ConcurrentHashMap<Object, Object>(5); c.ContainsValue(null); ShouldThrow(); } catch(NullReferenceException) { } }
public void TestReplaceValue3_NullReferenceException() { try { ConcurrentHashMap<Object, Object> c = new ConcurrentHashMap<Object, Object>(5); c.Replace("whatever", one, null); ShouldThrow(); } catch(NullReferenceException) { } }
public void TestRemove2_NullReferenceException() { try { ConcurrentHashMap<Object, Object> c = new ConcurrentHashMap<Object, Object>(5); c.Put("sadsdf", "asdads"); c.Remove(null, "whatever"); ShouldThrow(); } catch(NullReferenceException) { } }
public void TestRemove3() { try { ConcurrentHashMap<Object, Object> c = new ConcurrentHashMap<Object, Object>(5); c.Put("sadsdf", "asdads"); Assert.IsFalse(c.Remove("sadsdf", null)); } catch(NullReferenceException) { Assert.Fail(); } }
/// <summary>Creates a new, empty scheme registry.</summary> /// <remarks>Creates a new, empty scheme registry.</remarks> public SchemeRegistry() : base() { registeredSchemes = new ConcurrentHashMap <string, Apache.Http.Conn.Scheme.Scheme> (); }
public void TestSetValueWriteThrough() { ConcurrentHashMap<Object, Object> map = new ConcurrentHashMap<Object, Object>(2, 5.0f, 1); Assert.IsTrue(map.IsEmpty()); for (int i = 0; i < 20; i++) { map.Put(i, i); } Assert.IsFalse(map.IsEmpty()); Entry<Object, Object> entry1 = map.EntrySet().Iterator().Next(); // assert that entry1 is not 16 Assert.IsTrue(!entry1.Key.Equals(16), "entry is 16, test not valid"); // remove 16 (a different key) from map // which just happens to cause entry1 to be cloned in map map.Remove(16); entry1.Value = "XYZ"; Assert.IsTrue(map.ContainsValue("XYZ")); }
/// <summary> /// The ApplicationMaster is updating resource requirements for the /// application, by asking for more resources and releasing resources acquired /// by the application. /// </summary> /// <param name="requests">resources to be acquired</param> /// <param name="recoverPreemptedRequest">recover Resource Request on preemption</param> public virtual void UpdateResourceRequests(IList <ResourceRequest> requests, bool recoverPreemptedRequest) { lock (this) { QueueMetrics metrics = queue.GetMetrics(); // Update resource requests foreach (ResourceRequest request in requests) { Priority priority = request.GetPriority(); string resourceName = request.GetResourceName(); bool updatePendingResources = false; ResourceRequest lastRequest = null; if (resourceName.Equals(ResourceRequest.Any)) { if (Log.IsDebugEnabled()) { Log.Debug("update:" + " application=" + applicationId + " request=" + request); } updatePendingResources = true; // Premature optimization? // Assumes that we won't see more than one priority request updated // in one call, reasonable assumption... however, it's totally safe // to activate same application more than once. // Thus we don't need another loop ala the one in decrementOutstanding() // which is needed during deactivate. if (request.GetNumContainers() > 0) { activeUsersManager.ActivateApplication(user, applicationId); } } IDictionary <string, ResourceRequest> asks = this.requests[priority]; if (asks == null) { asks = new ConcurrentHashMap <string, ResourceRequest>(); this.requests[priority] = asks; this.priorities.AddItem(priority); } lastRequest = asks[resourceName]; if (recoverPreemptedRequest && lastRequest != null) { // Increment the number of containers to 1, as it is recovering a // single container. request.SetNumContainers(lastRequest.GetNumContainers() + 1); } asks[resourceName] = request; if (updatePendingResources) { // Similarly, deactivate application? if (request.GetNumContainers() <= 0) { Log.Info("checking for deactivate of application :" + this.applicationId); CheckForDeactivation(); } int lastRequestContainers = lastRequest != null?lastRequest.GetNumContainers() : 0; Org.Apache.Hadoop.Yarn.Api.Records.Resource lastRequestCapability = lastRequest != null?lastRequest.GetCapability() : Resources.None(); metrics.IncrPendingResources(user, request.GetNumContainers(), request.GetCapability ()); metrics.DecrPendingResources(user, lastRequestContainers, lastRequestCapability); } } } }
/// <summary> /// Default ctor /// </summary> public ConcurrentDictionary() { map = new ConcurrentHashMap <TKey, TValue>(); }
static Log() { // default "catch-all" tag enabledTags = new ConcurrentHashMap<string, int>(); enabledTags.Put(Log.Tag, Warn); enabledTags.Put(Log.TagSync, Warn); enabledTags.Put(Log.TagRemoteRequest, Warn); enabledTags.Put(Log.TagView, Warn); enabledTags.Put(Log.TagQuery, Warn); enabledTags.Put(Log.TagChangeTracker, Warn); enabledTags.Put(Log.TagRouter, Warn); enabledTags.Put(Log.TagDatabase, Warn); enabledTags.Put(Log.TagListener, Warn); enabledTags.Put(Log.TagMultiStreamWriter, Warn); enabledTags.Put(Log.TagBlobStore, Warn); }
/// <summary> /// Default ctor /// </summary> public ConcurrentDictionary(Java.Util.IMap <TKey, TValue> source) { map = new ConcurrentHashMap <TKey, TValue>(source); }
public void TestPutIfAbsent2_NullReferenceException() { try { ConcurrentHashMap<Object, Object> c = new ConcurrentHashMap<Object, Object>(5); c.PutIfAbsent("whatever", null); ShouldThrow(); } catch(NullReferenceException) { } }
public void TestPutAll() { ConcurrentHashMap<Object, Object> empty = new ConcurrentHashMap<Object, Object>(); ConcurrentHashMap<Object, Object> map = map5(); empty.PutAll(map); Assert.AreEqual(5, empty.Size()); Assert.IsTrue(empty.ContainsKey(one)); Assert.IsTrue(empty.ContainsKey(two)); Assert.IsTrue(empty.ContainsKey(three)); Assert.IsTrue(empty.ContainsKey(four)); Assert.IsTrue(empty.ContainsKey(five)); }
public void TestSize() { ConcurrentHashMap<Object, Object> map = map5(); ConcurrentHashMap<Object, Object> empty = new ConcurrentHashMap<Object, Object>(); Assert.AreEqual(0, empty.Size()); Assert.AreEqual(5, map.Size()); }
public AuthSchemeRegistry() : base() { this.registeredSchemes = new ConcurrentHashMap <string, AuthSchemeFactory>(); }
public void TestGetNullReferenceException() { try { ConcurrentHashMap<Object, Object> c = new ConcurrentHashMap<Object, Object>(5); c.Get(null); ShouldThrow(); } catch(NullReferenceException) { } }