Search in sources :

Example 6 with RedisDataType

use of org.apache.geode.redis.internal.RedisDataType in project geode by apache.

the class DelExecutor method executeCommand.

@Override
public void executeCommand(Command command, ExecutionHandlerContext context) {
    if (context.hasTransaction())
        throw new UnsupportedOperationInTransactionException();
    List<byte[]> commandElems = command.getProcessedCommand();
    if (commandElems.size() < 2) {
        command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.DEL));
        return;
    }
    int numRemoved = 0;
    for (int i = 1; i < commandElems.size(); i++) {
        byte[] byteKey = commandElems.get(i);
        ByteArrayWrapper key = new ByteArrayWrapper(byteKey);
        RedisDataType type = context.getRegionProvider().getRedisDataType(key);
        if (removeEntry(key, type, context))
            numRemoved++;
    }
    command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), numRemoved));
}
Also used : RedisDataType(org.apache.geode.redis.internal.RedisDataType) ByteArrayWrapper(org.apache.geode.redis.internal.ByteArrayWrapper) UnsupportedOperationInTransactionException(org.apache.geode.cache.UnsupportedOperationInTransactionException)

Example 7 with RedisDataType

use of org.apache.geode.redis.internal.RedisDataType in project geode by apache.

the class FlushAllExecutor method executeCommand.

@Override
public void executeCommand(Command command, ExecutionHandlerContext context) {
    if (context.hasTransaction())
        throw new UnsupportedOperationInTransactionException();
    for (Entry<String, RedisDataType> e : context.getRegionProvider().metaEntrySet()) {
        try {
            String skey = e.getKey();
            RedisDataType type = e.getValue();
            removeEntry(Coder.stringToByteWrapper(skey), type, context);
        } catch (EntryDestroyedException e1) {
            continue;
        }
    }
    command.setResponse(Coder.getSimpleStringResponse(context.getByteBufAllocator(), "OK"));
}
Also used : RedisDataType(org.apache.geode.redis.internal.RedisDataType) EntryDestroyedException(org.apache.geode.cache.EntryDestroyedException) UnsupportedOperationInTransactionException(org.apache.geode.cache.UnsupportedOperationInTransactionException)

Example 8 with RedisDataType

use of org.apache.geode.redis.internal.RedisDataType in project geode by apache.

the class TypeExecutor method executeCommand.

@Override
public void executeCommand(Command command, ExecutionHandlerContext context) {
    List<byte[]> commandElems = command.getProcessedCommand();
    if (commandElems.size() < 2) {
        command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.TYPE));
        return;
    }
    ByteArrayWrapper key = command.getKey();
    RedisDataType type = context.getRegionProvider().getRedisDataType(key);
    if (type == null)
        command.setResponse(Coder.getBulkStringResponse(context.getByteBufAllocator(), "none"));
    else
        command.setResponse(Coder.getBulkStringResponse(context.getByteBufAllocator(), type.toString()));
}
Also used : RedisDataType(org.apache.geode.redis.internal.RedisDataType) ByteArrayWrapper(org.apache.geode.redis.internal.ByteArrayWrapper)

Aggregations

RedisDataType (org.apache.geode.redis.internal.RedisDataType)8 ByteArrayWrapper (org.apache.geode.redis.internal.ByteArrayWrapper)5 IOException (java.io.IOException)2 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)2 UnsupportedOperationInTransactionException (org.apache.geode.cache.UnsupportedOperationInTransactionException)2 RegionProvider (org.apache.geode.redis.internal.RegionProvider)2 UnknownHostException (java.net.UnknownHostException)1 Entry (java.util.Map.Entry)1 InternalGemFireError (org.apache.geode.InternalGemFireError)1 AttributesFactory (org.apache.geode.cache.AttributesFactory)1 EntryDestroyedException (org.apache.geode.cache.EntryDestroyedException)1 InternalCache (org.apache.geode.internal.cache.InternalCache)1 InternalRegionArguments (org.apache.geode.internal.cache.InternalRegionArguments)1 HyperLogLogPlus (org.apache.geode.internal.hll.HyperLogLogPlus)1