Revision 6711
Added by Chris Jones almost 13 years ago
src/edu/ucsb/nceas/metacat/dataone/hazelcast/HazelcastService.java | ||
---|---|---|
42 | 42 |
import com.hazelcast.core.EntryEvent; |
43 | 43 |
import com.hazelcast.core.EntryListener; |
44 | 44 |
import com.hazelcast.core.Hazelcast; |
45 |
import com.hazelcast.core.HazelcastInstance; |
|
45 | 46 |
import com.hazelcast.core.ILock; |
46 | 47 |
import com.hazelcast.core.IMap; |
47 | 48 |
import com.hazelcast.core.InstanceEvent; |
... | ... | |
104 | 105 |
|
105 | 106 |
/* The Hazelcast distributed system metadata map */ |
106 | 107 |
private IMap<Identifier, SystemMetadata> systemMetadata; |
108 |
|
|
109 |
private HazelcastInstance hzInstance; |
|
107 | 110 |
|
108 | 111 |
/* |
109 | 112 |
* Constructor: Creates an instance of the hazelcast service. Since |
... | ... | |
167 | 170 |
} |
168 | 171 |
|
169 | 172 |
Hazelcast.init(config); |
170 |
|
|
173 |
this.hzInstance = Hazelcast.getDefaultInstance(); |
|
174 |
|
|
171 | 175 |
// Get configuration properties on instantiation |
172 | 176 |
try { |
173 | 177 |
groupName = |
... | ... | |
229 | 233 |
ILock lock = null; |
230 | 234 |
|
231 | 235 |
try { |
232 |
lock = getInstance().getLock(identifier); |
|
236 |
lock = getInstance().getHazelcastInstance().getLock(identifier);
|
|
233 | 237 |
|
234 | 238 |
} catch (RuntimeException e) { |
235 | 239 |
logMetacat.info("Couldn't get a lock for identifier " + |
... | ... | |
288 | 292 |
event.getInstance().getInstanceType()); |
289 | 293 |
|
290 | 294 |
} |
295 |
|
|
296 |
public HazelcastInstance getHazelcastInstance() { |
|
297 |
return this.hzInstance; |
|
298 |
|
|
299 |
} |
|
291 | 300 |
|
292 | 301 |
/** |
293 | 302 |
* Refresh the Hazelcast service by restarting it |
Also available in: Unified diff
Set a default HazelcastInstance after init() is called, and use this instance in getLock() to acquire a lock in the cluster.