Search in sources :

Example 1 with ExecutablePool

use of org.apache.geode.cache.client.internal.ExecutablePool in project geode by apache.

the class ClientTypeRegistration method getType.

public PdxType getType(int typeId) {
    Collection<Pool> pools = getAllPools();
    ServerConnectivityException lastException = null;
    for (Pool pool : pools) {
        try {
            PdxType type = GetPDXTypeByIdOp.execute((ExecutablePool) pool, typeId);
            if (type != null) {
                return type;
            }
        } catch (ServerConnectivityException e) {
            logger.debug("Received an exception getting pdx type from pool {}, {}", pool, e.getMessage(), e);
            // ignore, try the next pool.
            lastException = e;
        }
    }
    if (lastException != null) {
        throw lastException;
    } else {
        throw returnCorrectExceptionForFailure(pools, typeId, lastException);
    }
}
Also used : ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) ExecutablePool(org.apache.geode.cache.client.internal.ExecutablePool) Pool(org.apache.geode.cache.client.Pool)

Example 2 with ExecutablePool

use of org.apache.geode.cache.client.internal.ExecutablePool in project geode by apache.

the class ClientTypeRegistration method defineType.

public int defineType(PdxType newType) {
    Collection<Pool> pools = getAllPools();
    ServerConnectivityException lastException = null;
    int newTypeId = -1;
    for (Pool pool : pools) {
        try {
            newTypeId = GetPDXIdForTypeOp.execute((ExecutablePool) pool, newType);
            newType.setTypeId(newTypeId);
            sendTypeToPool(newType, newTypeId, pool);
            return newTypeId;
        } catch (ServerConnectivityException e) {
            // ignore, try the next pool.
            lastException = e;
        }
    }
    throw returnCorrectExceptionForFailure(pools, newTypeId, lastException);
}
Also used : ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) ExecutablePool(org.apache.geode.cache.client.internal.ExecutablePool) ExecutablePool(org.apache.geode.cache.client.internal.ExecutablePool) Pool(org.apache.geode.cache.client.Pool)

Example 3 with ExecutablePool

use of org.apache.geode.cache.client.internal.ExecutablePool in project geode by apache.

the class ClientTypeRegistration method enums.

@SuppressWarnings({ "unchecked", "serial" })
@Override
public Map<Integer, EnumInfo> enums() {
    Collection<Pool> pools = getAllPools();
    Map<Integer, EnumInfo> enums = new HashMap<>();
    for (Pool p : pools) {
        enums.putAll(GetPDXEnumsOp.execute((ExecutablePool) p));
    }
    return enums;
}
Also used : ExecutablePool(org.apache.geode.cache.client.internal.ExecutablePool) HashMap(java.util.HashMap) ExecutablePool(org.apache.geode.cache.client.internal.ExecutablePool) Pool(org.apache.geode.cache.client.Pool)

Example 4 with ExecutablePool

use of org.apache.geode.cache.client.internal.ExecutablePool in project geode by apache.

the class ClientTypeRegistration method types.

@SuppressWarnings({ "unchecked", "serial" })
@Override
public Map<Integer, PdxType> types() {
    Collection<Pool> pools = getAllPools();
    Map<Integer, PdxType> types = new HashMap<>();
    for (Pool p : pools) {
        try {
            types.putAll(GetPDXTypesOp.execute((ExecutablePool) p));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return types;
}
Also used : ExecutablePool(org.apache.geode.cache.client.internal.ExecutablePool) HashMap(java.util.HashMap) ExecutablePool(org.apache.geode.cache.client.internal.ExecutablePool) Pool(org.apache.geode.cache.client.Pool) CacheClosedException(org.apache.geode.cache.CacheClosedException) ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException)

Example 5 with ExecutablePool

use of org.apache.geode.cache.client.internal.ExecutablePool in project geode by apache.

the class ClientTypeRegistration method processEnumInfoForEnumId.

private int processEnumInfoForEnumId(EnumInfo enumInfo) {
    Collection<Pool> pools = getAllPools();
    ServerConnectivityException lastException = null;
    for (Pool pool : pools) {
        try {
            int result = GetPDXIdForEnumOp.execute((ExecutablePool) pool, enumInfo);
            sendEnumIdToPool(enumInfo, result, pool);
            return result;
        } catch (ServerConnectivityException e) {
            // ignore, try the next pool.
            lastException = e;
        }
    }
    throw returnCorrectExceptionForFailure(pools, -1, lastException);
}
Also used : ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) ExecutablePool(org.apache.geode.cache.client.internal.ExecutablePool) Pool(org.apache.geode.cache.client.Pool)

Aggregations

Pool (org.apache.geode.cache.client.Pool)6 ExecutablePool (org.apache.geode.cache.client.internal.ExecutablePool)6 ServerConnectivityException (org.apache.geode.cache.client.ServerConnectivityException)5 HashMap (java.util.HashMap)2 CacheClosedException (org.apache.geode.cache.CacheClosedException)1