Yuta HIGUCHI

remove synchronized

Change-Id: I1a11e48d042797744a4ac834fd65f6417c700f57
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
15 */ 15 */
16 package org.onlab.onos.store.core.impl; 16 package org.onlab.onos.store.core.impl;
17 17
18 +import static org.apache.commons.lang3.concurrent.ConcurrentUtils.putIfAbsent;
19 +
18 import com.google.common.collect.ImmutableSet; 20 import com.google.common.collect.ImmutableSet;
19 import com.hazelcast.core.EntryEvent; 21 import com.hazelcast.core.EntryEvent;
20 import com.hazelcast.core.EntryListener; 22 import com.hazelcast.core.EntryListener;
...@@ -97,20 +99,19 @@ public class DistributedApplicationIdStore ...@@ -97,20 +99,19 @@ public class DistributedApplicationIdStore
97 return appId; 99 return appId;
98 } 100 }
99 101
100 - private synchronized void primeAppIds() { 102 + private void primeAppIds() {
101 for (DefaultApplicationId appId : appIdsByName.values()) { 103 for (DefaultApplicationId appId : appIdsByName.values()) {
102 appIds.put(appId.id(), appId); 104 appIds.put(appId.id(), appId);
103 } 105 }
104 } 106 }
105 107
106 @Override 108 @Override
107 - public synchronized ApplicationId registerApplication(String name) { 109 + public ApplicationId registerApplication(String name) {
108 DefaultApplicationId appId = appIdsByName.get(name); 110 DefaultApplicationId appId = appIdsByName.get(name);
109 if (appId == null) { 111 if (appId == null) {
110 short id = (short) lastAppId.getAndIncrement(); 112 short id = (short) lastAppId.getAndIncrement();
111 - appId = new DefaultApplicationId(id, name); 113 + appId = putIfAbsent(appIdsByName, name,
112 - appIds.put(id, appId); 114 + new DefaultApplicationId(id, name));
113 - appIdsByName.put(name, appId);
114 } 115 }
115 return appId; 116 return appId;
116 } 117 }
......