當前位置: 首頁>>代碼示例>>Java>>正文


Java JedisDataException類代碼示例

本文整理匯總了Java中redis.clients.jedis.exceptions.JedisDataException的典型用法代碼示例。如果您正苦於以下問題:Java JedisDataException類的具體用法?Java JedisDataException怎麽用?Java JedisDataException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JedisDataException類屬於redis.clients.jedis.exceptions包,在下文中一共展示了JedisDataException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: exec

import redis.clients.jedis.exceptions.JedisDataException; //導入依賴的package包/類
public List<Object> exec() {
   	// Discard QUEUED or ERROR
   	client.getMany(getPipelinedResponseLength());
	client.exec();
	//client.getAll(1); // Discard all but the last reply
	inTransaction = false;

	List<Object> unformatted = client.getObjectMultiBulkReply();
	if (unformatted == null) {
		return null;
	}
	List<Object> formatted = new ArrayList<Object>();
	for (Object o : unformatted) {
		try {
			formatted.add(generateResponse(o).get());
		} catch (JedisDataException e) {
			formatted.add(e);
		}
	}
	return formatted;
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:22,代碼來源:Transaction.java

示例2: processError

import redis.clients.jedis.exceptions.JedisDataException; //導入依賴的package包/類
private static void processError(final RedisInputStream is) {
	String message = is.readLine();
	// TODO: I'm not sure if this is the best way to do this.
	// Maybe Read only first 5 bytes instead?
	if (message.startsWith(MOVED_RESPONSE)) {
		String[] movedInfo = parseTargetHostAndSlot(message);
		throw new JedisMovedDataException(message, new HostAndPort(movedInfo[1], Integer.valueOf(movedInfo[2])),
				Integer.valueOf(movedInfo[0]));
	} else if (message.startsWith(ASK_RESPONSE)) {
		String[] askInfo = parseTargetHostAndSlot(message);
		throw new JedisAskDataException(message, new HostAndPort(askInfo[1], Integer.valueOf(askInfo[2])),
				Integer.valueOf(askInfo[0]));
	} else if (message.startsWith(CLUSTERDOWN_RESPONSE)) {
		throw new JedisClusterException(message);
	} else if (message.startsWith(BUSY_RESPONSE)) {
		throw new JedisBusyException(message);
	} else if (message.startsWith(NOSCRIPT_RESPONSE)) {
		throw new JedisNoScriptException(message);
	}
	throw new JedisDataException(message);
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:22,代碼來源:Protocol.java

示例3: get

import redis.clients.jedis.exceptions.JedisDataException; //導入依賴的package包/類
public T get() {
	// if response has dependency response and dependency is not built,
	// build it first and no more!!
	if (dependency != null && dependency.set && !dependency.built) {
		dependency.build();
	}
	if (!set) {
		throw new JedisDataException("Please close pipeline or multi block before calling this method.");
	}
	if (!built) {
		build();
	}
	if (exception != null) {
		throw exception;
	}
	return response;
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:18,代碼來源:Response.java

示例4: build

import redis.clients.jedis.exceptions.JedisDataException; //導入依賴的package包/類
private void build() {
	// check build state to prevent recursion
	if (building) {
		return;
	}

	building = true;
	try {
		if (data != null) {
			if (data instanceof JedisDataException) {
				exception = (JedisDataException) data;
			} else {
				response = builder.build(data);
			}
		}

		data = null;
	} finally {
		building = false;
		built = true;
	}
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:23,代碼來源:Response.java

示例5: build

import redis.clients.jedis.exceptions.JedisDataException; //導入依賴的package包/類
@Override
public List<Object> build(Object data) {
  @SuppressWarnings("unchecked")
  List<Object> list = (List<Object>) data;
  List<Object> values = new ArrayList<Object>();

  if (list.size() != responses.size()) {
    throw new JedisDataException("Expected data size " + responses.size() + " but was "
        + list.size());
  }

  for (int i = 0; i < list.size(); i++) {
    Response<?> response = responses.get(i);
    response.set(list.get(i));
    Object builtResponse;
    try {
      builtResponse = response.get();
    } catch (JedisDataException e) {
      builtResponse = e;
    }
    values.add(builtResponse);
  }
  return values;
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:25,代碼來源:Pipeline.java

示例6: syncAndReturnAll

import redis.clients.jedis.exceptions.JedisDataException; //導入依賴的package包/類
/**
 * Synchronize pipeline by reading all responses. This operation close the pipeline. Whenever
 * possible try to avoid using this version and use Pipeline.sync() as it won't go through all the
 * responses and generate the right response type (usually it is a waste of time).
 * @return A list of all the responses in the order you executed them.
 */
public List<Object> syncAndReturnAll() {
  if (getPipelinedResponseLength() > 0) {
    List<Object> unformatted = client.getAll();
    List<Object> formatted = new ArrayList<Object>();

    for (Object o : unformatted) {
      try {
        formatted.add(generateResponse(o).get());
      } catch (JedisDataException e) {
        formatted.add(e);
      }
    }
    return formatted;
  } else {
    return java.util.Collections.<Object> emptyList();
  }
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:24,代碼來源:Pipeline.java

示例7: transactionResponseWithError

import redis.clients.jedis.exceptions.JedisDataException; //導入依賴的package包/類
@Test
public void transactionResponseWithError() {
  Transaction t = jedis.multi();
  t.set("foo", "bar");
  Response<Set<String>> error = t.smembers("foo");
  Response<String> r = t.get("foo");
  List<Object> l = t.exec();
  assertEquals(JedisDataException.class, l.get(1).getClass());
  try {
    error.get();
    fail("We expect exception here!");
  } catch (JedisDataException e) {
    // that is fine we should be here
  }
  assertEquals(r.get(), "bar");
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:17,代碼來源:TransactionCommandsTest.java

示例8: execGetResponse

import redis.clients.jedis.exceptions.JedisDataException; //導入依賴的package包/類
@Test
public void execGetResponse() {
  Transaction t = jedis.multi();

  t.set("foo", "bar");
  t.smembers("foo");
  t.get("foo");

  List<Response<?>> lr = t.execGetResponse();
  try {
    lr.get(1).get();
    fail("We expect exception here!");
  } catch (JedisDataException e) {
    // that is fine we should be here
  }
  assertEquals("bar", lr.get(2).get());
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:18,代碼來源:TransactionCommandsTest.java

示例9: testCloseable

import redis.clients.jedis.exceptions.JedisDataException; //導入依賴的package包/類
@Test
public void testCloseable() throws IOException {
  // we need to test with fresh instance of Jedis
  Jedis jedis2 = new Jedis(hnp.getHost(), hnp.getPort(), 500);
  jedis2.auth("foobared");

  Transaction transaction = jedis2.multi();
  transaction.set("a", "1");
  transaction.set("b", "2");

  transaction.close();

  try {
    transaction.exec();
    fail("close should discard transaction");
  } catch (JedisDataException e) {
    assertTrue(e.getMessage().contains("EXEC without MULTI"));
    // pass
  }
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:21,代碼來源:TransactionCommandsTest.java

示例10: sentinelMonitor

import redis.clients.jedis.exceptions.JedisDataException; //導入依賴的package包/類
@Test
public void sentinelMonitor() {
  Jedis j = new Jedis(sentinel.getHost(), sentinel.getPort());

  try {
    // monitor new master
    String result = j.sentinelMonitor(MONITOR_MASTER_NAME, MASTER_IP, master.getPort(), 1);
    assertEquals("OK", result);

    // already monitored
    try {
      j.sentinelMonitor(MONITOR_MASTER_NAME, MASTER_IP, master.getPort(), 1);
      fail();
    } catch (JedisDataException e) {
      // pass
    }
  } finally {
    j.close();
  }
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:21,代碼來源:JedisSentinelTest.java

示例11: sentinelRemove

import redis.clients.jedis.exceptions.JedisDataException; //導入依賴的package包/類
@Test
public void sentinelRemove() {
  Jedis j = new Jedis(sentinel.getHost(), sentinel.getPort());

  try {
    ensureMonitored(sentinel, REMOVE_MASTER_NAME, MASTER_IP, master.getPort(), 1);

    String result = j.sentinelRemove(REMOVE_MASTER_NAME);
    assertEquals("OK", result);

    // not exist
    try {
      result = j.sentinelRemove(REMOVE_MASTER_NAME);
      assertNotEquals("OK", result);
      fail();
    } catch (JedisDataException e) {
      // pass
    }
  } finally {
    j.close();
  }
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:23,代碼來源:JedisSentinelTest.java

示例12: exec

import redis.clients.jedis.exceptions.JedisDataException; //導入依賴的package包/類
public List<Object> exec() {
  client.exec();
  client.getAll(1); // Discard all but the last reply
  inTransaction = false;

  List<Object> unformatted = client.getObjectMultiBulkReply();
  if (unformatted == null) {
    return null;
  }
  List<Object> formatted = new ArrayList<Object>();
  for (Object o : unformatted) {
    try {
      formatted.add(generateResponse(o).get());
    } catch (JedisDataException e) {
      formatted.add(e);
    }
  }
  return formatted;
}
 
開發者ID:x7-framework,項目名稱:x7,代碼行數:20,代碼來源:Transaction.java

示例13: processError

import redis.clients.jedis.exceptions.JedisDataException; //導入依賴的package包/類
private static void processError(final RedisInputStream is) {
  String message = is.readLine();
  // TODO: I'm not sure if this is the best way to do this.
  // Maybe Read only first 5 bytes instead?
  if (message.startsWith(MOVED_RESPONSE)) {
    String[] movedInfo = parseTargetHostAndSlot(message);
    throw new JedisMovedDataException(message, new HostAndPort(movedInfo[1],
        Integer.valueOf(movedInfo[2])), Integer.valueOf(movedInfo[0]));
  } else if (message.startsWith(ASK_RESPONSE)) {
    String[] askInfo = parseTargetHostAndSlot(message);
    throw new JedisAskDataException(message, new HostAndPort(askInfo[1],
        Integer.valueOf(askInfo[2])), Integer.valueOf(askInfo[0]));
  } else if (message.startsWith(CLUSTERDOWN_RESPONSE)) {
    throw new JedisClusterException(message);
  }
  throw new JedisDataException(message);
}
 
開發者ID:x7-framework,項目名稱:x7,代碼行數:18,代碼來源:Protocol.java

示例14: get

import redis.clients.jedis.exceptions.JedisDataException; //導入依賴的package包/類
public T get() {
  // if response has dependency response and dependency is not built,
  // build it first and no more!!
  if (dependency != null && dependency.set && !dependency.built) {
    dependency.build();
  }
  if (!set) {
    throw new JedisDataException(
        "Please close pipeline or multi block before calling this method.");
  }
  if (!built) {
    build();
  }
  if (exception != null) {
    throw exception;
  }
  return response;
}
 
開發者ID:x7-framework,項目名稱:x7,代碼行數:19,代碼來源:Response.java

示例15: build

import redis.clients.jedis.exceptions.JedisDataException; //導入依賴的package包/類
private void build() {
  // check build state to prevent recursion
  if (building) {
    return;
  }

  building = true;
  try {
    if (data != null) {
      if (data instanceof JedisDataException) {
        exception = (JedisDataException) data;
      } else {
        response = builder.build(data);
      }
    }

    data = null;
  } finally {
    building = false;
    built = true;
  }
}
 
開發者ID:x7-framework,項目名稱:x7,代碼行數:23,代碼來源:Response.java


注:本文中的redis.clients.jedis.exceptions.JedisDataException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。