use of com.hazelcast.core.HazelcastException in project hazelcast by hazelcast.
the class PostJoinCacheOperationTest method test_cachePostJoinOperationFails_whenJCacheNotAvailable_withCacheConfigs.
@Test
public void test_cachePostJoinOperationFails_whenJCacheNotAvailable_withCacheConfigs() throws Exception {
// JCache is not available in classpath
when(JCacheDetector.isJCacheAvailable(classLoader)).thenReturn(false);
// node engine throws HazelcastException due to missing CacheService
when(nodeEngine.getService(CacheService.SERVICE_NAME)).thenThrow(new HazelcastException("CacheService not found"));
// some CacheConfigs are added in the PostJoinCacheOperation (so JCache is actually in use in the rest of the cluster)
PostJoinCacheOperation postJoinCacheOperation = new PostJoinCacheOperation();
postJoinCacheOperation.addCacheConfig(new CacheConfig("test"));
postJoinCacheOperation.setNodeEngine(nodeEngine);
expectedException.expect(HazelcastException.class);
postJoinCacheOperation.run();
verify(nodeEngine).getConfigClassLoader();
verify(nodeEngine).getService(CacheService.SERVICE_NAME);
verify(logger, never()).warning(anyString());
}
use of com.hazelcast.core.HazelcastException in project hazelcast by hazelcast.
the class XmlClientConfigLocator method loadClientHazelcastXmlFromClasspath.
private boolean loadClientHazelcastXmlFromClasspath() {
URL url = Config.class.getClassLoader().getResource("hazelcast-client.xml");
if (url == null) {
LOGGER.finest("Could not find 'hazelcast-client.xml' in classpath.");
return false;
}
LOGGER.info("Loading 'hazelcast-client.xml' from classpath.");
in = Config.class.getClassLoader().getResourceAsStream("hazelcast-client.xml");
if (in == null) {
throw new HazelcastException("Could not load 'hazelcast-client.xml' from classpath");
}
return true;
}
use of com.hazelcast.core.HazelcastException in project hazelcast by hazelcast.
the class RingbufferContainer method addAll.
/**
* Adds all items to the ring buffer. Sets the expiration time if TTL is configured and also attempts to store the items
* in the data store if one is configured.
*
* @param items items to be stored in the ring buffer and data store
* @return the sequence id of the last item stored in the ring buffer
* @throws HazelcastException if there was any exception thrown by the data store
* @throws com.hazelcast.nio.serialization.HazelcastSerializationException if the ring buffer is configured to keep items
* in object format and the item could not be
* deserialized
*/
public long addAll(Data[] items) {
long firstSequence = -1;
long lastSequence = -1;
for (int i = 0; i < items.length; i++) {
lastSequence = addInternal(items[i]);
if (i == 0) {
firstSequence = lastSequence;
}
}
if (store.isEnabled() && items.length != 0) {
try {
store.storeAll(firstSequence, items);
} catch (Exception e) {
throw new HazelcastException(e);
}
}
return lastSequence;
}
use of com.hazelcast.core.HazelcastException in project hazelcast by hazelcast.
the class ClientSmartInvocationServiceImpl method ensureOwnerConnectionAvailable.
private void ensureOwnerConnectionAvailable() throws IOException {
ClientClusterService clientClusterService = client.getClientClusterService();
Address ownerConnectionAddress = clientClusterService.getOwnerConnectionAddress();
boolean isOwnerConnectionAvailable = ownerConnectionAddress != null && connectionManager.getConnection(ownerConnectionAddress) != null;
if (!isOwnerConnectionAvailable) {
if (isShutdown()) {
throw new HazelcastException("ConnectionManager is not active!");
}
throw new IOException("Not able to setup owner connection!");
}
}
use of com.hazelcast.core.HazelcastException in project hazelcast by hazelcast.
the class XmlConfigLocator method loadFromWorkingDirectory.
private boolean loadFromWorkingDirectory() {
File file = new File("hazelcast.xml");
if (!file.exists()) {
LOGGER.finest("Could not find 'hazelcast.xml' in working directory.");
return false;
}
LOGGER.info("Loading 'hazelcast.xml' from working directory.");
configurationFile = file;
try {
in = new FileInputStream(file);
} catch (FileNotFoundException e) {
throw new HazelcastException("Failed to open file: " + file.getAbsolutePath(), e);
}
return true;
}
Aggregations