Search in sources :

Example 71 with HazelcastException

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!");
    }
}
Also used : HazelcastException(com.hazelcast.core.HazelcastException) Address(com.hazelcast.nio.Address) IOException(java.io.IOException) ClientClusterService(com.hazelcast.client.spi.ClientClusterService)

Example 72 with HazelcastException

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;
}
Also used : HazelcastException(com.hazelcast.core.HazelcastException) FileNotFoundException(java.io.FileNotFoundException) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 73 with HazelcastException

use of com.hazelcast.core.HazelcastException in project hazelcast by hazelcast.

the class MapProxyImpl method aggregate.

@Override
public <SuppliedValue, Result> Result aggregate(Supplier<K, V, SuppliedValue> supplier, Aggregation<K, SuppliedValue, Result> aggregation, JobTracker jobTracker) {
    checkTrue(NATIVE != mapConfig.getInMemoryFormat(), "NATIVE storage format is not supported for MapReduce");
    try {
        isNotNull(jobTracker, "jobTracker");
        KeyValueSource<K, V> keyValueSource = KeyValueSource.fromMap(this);
        Job<K, V> job = jobTracker.newJob(keyValueSource);
        Mapper mapper = aggregation.getMapper(supplier);
        CombinerFactory combinerFactory = aggregation.getCombinerFactory();
        ReducerFactory reducerFactory = aggregation.getReducerFactory();
        Collator collator = aggregation.getCollator();
        MappingJob mappingJob = job.mapper(mapper);
        ReducingSubmittableJob reducingJob;
        if (combinerFactory == null) {
            reducingJob = mappingJob.reducer(reducerFactory);
        } else {
            reducingJob = mappingJob.combiner(combinerFactory).reducer(reducerFactory);
        }
        ICompletableFuture<Result> future = reducingJob.submit(collator);
        return future.get();
    } catch (Exception e) {
        // TODO: not what we want, because it can lead to wrapping of HazelcastException
        throw new HazelcastException(e);
    }
}
Also used : MappingJob(com.hazelcast.mapreduce.MappingJob) HazelcastException(com.hazelcast.core.HazelcastException) ReducerFactory(com.hazelcast.mapreduce.ReducerFactory) HazelcastException(com.hazelcast.core.HazelcastException) Collator(com.hazelcast.mapreduce.Collator) AggregationResult(com.hazelcast.map.impl.query.AggregationResult) QueryResult(com.hazelcast.map.impl.query.QueryResult) CombinerFactory(com.hazelcast.mapreduce.CombinerFactory) Mapper(com.hazelcast.mapreduce.Mapper) ReducingSubmittableJob(com.hazelcast.mapreduce.ReducingSubmittableJob)

Example 74 with HazelcastException

use of com.hazelcast.core.HazelcastException in project hazelcast by hazelcast.

the class ClientMapProxy method aggregate.

@Override
public <SuppliedValue, Result> Result aggregate(Supplier<K, V, SuppliedValue> supplier, Aggregation<K, SuppliedValue, Result> aggregation, JobTracker jobTracker) {
    try {
        Preconditions.isNotNull(jobTracker, "jobTracker");
        KeyValueSource<K, V> keyValueSource = KeyValueSource.fromMap(this);
        Job<K, V> job = jobTracker.newJob(keyValueSource);
        Mapper mapper = aggregation.getMapper(supplier);
        CombinerFactory combinerFactory = aggregation.getCombinerFactory();
        ReducerFactory reducerFactory = aggregation.getReducerFactory();
        Collator collator = aggregation.getCollator();
        MappingJob mappingJob = job.mapper(mapper);
        ReducingSubmittableJob reducingJob;
        if (combinerFactory != null) {
            reducingJob = mappingJob.combiner(combinerFactory).reducer(reducerFactory);
        } else {
            reducingJob = mappingJob.reducer(reducerFactory);
        }
        ICompletableFuture<Result> future = reducingJob.submit(collator);
        return future.get();
    } catch (Exception e) {
        throw new HazelcastException(e);
    }
}
Also used : MappingJob(com.hazelcast.mapreduce.MappingJob) HazelcastException(com.hazelcast.core.HazelcastException) ReducerFactory(com.hazelcast.mapreduce.ReducerFactory) HazelcastException(com.hazelcast.core.HazelcastException) Collator(com.hazelcast.mapreduce.Collator) CombinerFactory(com.hazelcast.mapreduce.CombinerFactory) Mapper(com.hazelcast.mapreduce.Mapper) ReducingSubmittableJob(com.hazelcast.mapreduce.ReducingSubmittableJob)

Example 75 with HazelcastException

use of com.hazelcast.core.HazelcastException in project hazelcast by hazelcast.

the class QueueContainer method mapDrainIterator.

public void mapDrainIterator(int maxSize, Map map) {
    Iterator<QueueItem> iter = getItemQueue().iterator();
    for (int i = 0; i < maxSize; i++) {
        QueueItem item = iter.next();
        if (store.isEnabled() && item.getData() == null) {
            try {
                load(item);
            } catch (Exception e) {
                throw new HazelcastException(e);
            }
        }
        map.put(item.getItemId(), item.getData());
    }
}
Also used : HazelcastException(com.hazelcast.core.HazelcastException) TxQueueItem(com.hazelcast.collection.impl.txnqueue.TxQueueItem) TransactionException(com.hazelcast.transaction.TransactionException) HazelcastException(com.hazelcast.core.HazelcastException) IOException(java.io.IOException)

Aggregations

HazelcastException (com.hazelcast.core.HazelcastException)123 IOException (java.io.IOException)43 QuickTest (com.hazelcast.test.annotation.QuickTest)19 Test (org.junit.Test)19 TxQueueItem (com.hazelcast.collection.impl.txnqueue.TxQueueItem)14 TransactionException (com.hazelcast.transaction.TransactionException)14 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)13 File (java.io.File)13 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)8 FileInputStream (java.io.FileInputStream)8 FileNotFoundException (java.io.FileNotFoundException)8 Data (com.hazelcast.internal.serialization.Data)7 OOfflineNodeException (com.orientechnologies.common.concur.OOfflineNodeException)6 Future (java.util.concurrent.Future)6 ONeedRetryException (com.orientechnologies.common.concur.ONeedRetryException)5 OException (com.orientechnologies.common.exception.OException)5 OIOException (com.orientechnologies.common.io.OIOException)5 ODistributedRedirectException (com.orientechnologies.orient.enterprise.channel.binary.ODistributedRedirectException)5 EOFException (java.io.EOFException)5 ArrayList (java.util.ArrayList)5