@Test public void getLastMessagesTest() { String channelName = "aidr_predict.mock_collection"; int msgCount = 2; List<String> list = channelBufferManager.getLastMessages(channelName, msgCount); assertNotNull(list); boolean isString = false; String stringList = list.get(0); if(stringList != null) isString = true; assertEquals(true, isString); }
public List<String> getLastMessages(String channelName, int msgCount) { if (isChannelPresent(channelName)) { ChannelBuffer cb = subscribedChannels.get(channelName); try { return cb != null ? cb.getMessages(Math.min(2 * msgCount, ChannelBuffer.MAX_FETCH_SIZE)) : null; } catch (Exception e) { logger.error("Failed to retrieve messages from buffer for channel: " + channelName); } } return null; }
ChannelBufferManager { public List<String> getLastMessages(String channelName, int msgCount) { if (isChannelPresent(channelName)) { ChannelBuffer cb = subscribedChannels.get(channelName); try { return cb != null ? cb.getMessages(Math.min(2 * msgCount, ChannelBuffer.MAX_FETCH_SIZE)) : null; } catch (Exception e) { logger.error("Failed to retrieve messages from buffer for channel: " + channelName); } } return null; } }
ChannelBufferManager { public List<String> getLastMessages(String channelName, int msgCount) { if (isChannelPresent(channelName)) { ChannelBuffer cb = subscribedChannels.get(channelName); try { return cb != null ? cb.getMessages(Math.min(2 * msgCount, ChannelBuffer.MAX_FETCH_SIZE)) : null; } catch (Exception e) { logger.error("Failed to retrieve messages from buffer for channel: " + channelName); } } return null; } ChannelBufferManager(); }
ChannelBufferManager { public List<String> getLastMessages(String channelName, int msgCount) { if (isChannelPresent(channelName)) { ChannelBuffer cb = subscribedChannels.get(channelName); try { return cb != null ? cb.getMessages(Math.min(2 * msgCount, ChannelBuffer.MAX_FETCH_SIZE)) : null; } catch (Exception e) { logger.error("Failed to retrieve messages from buffer for channel: " + channelName); } } return null; } ChannelBufferManager(); void initiateChannelBufferManager(final String channelRegEx); ExecutorService getExecutorServicePool(); void initiateChannelBufferManager(final int bufferSize, final String channelRegEx); void manageChannelBuffersWrapper(final String subscriptionPattern, final String channelName, 
			final String receivedMessage); void manageChannelBuffers(final String subscriptionPattern, final String channelName, 
			final String receivedMessage); void addMessageToChannelBuffer(final String channelName, final String msg); List<String> getLastMessages(String channelName, int msgCount); boolean isChannelPresent(String channelName); void createChannelQueue(final String channelName); void deleteChannelBuffer(final String channelName); void deleteAllChannelBuffers(); Set<String> getActiveChannelsList(); Set<String> getActiveChannelCodes(); @SuppressWarnings("unchecked") Boolean getChannelPublicStatus(String channelName); @SuppressWarnings("unchecked") Map<String, Boolean> getAllRunningCollections(); List<String> getLatestFromAllChannels(final int msgCount); String parseChannelName(String channelName); void close(); }
ChannelBufferManager { public List<String> getLastMessages(String channelName, int msgCount) { if (isChannelPresent(channelName)) { ChannelBuffer cb = subscribedChannels.get(channelName); try { return cb != null ? cb.getMessages(Math.min(2 * msgCount, ChannelBuffer.MAX_FETCH_SIZE)) : null; } catch (Exception e) { logger.error("Failed to retrieve messages from buffer for channel: " + channelName); } } return null; } ChannelBufferManager(); void initiateChannelBufferManager(final String channelRegEx); ExecutorService getExecutorServicePool(); void initiateChannelBufferManager(final int bufferSize, final String channelRegEx); void manageChannelBuffersWrapper(final String subscriptionPattern, final String channelName, 
			final String receivedMessage); void manageChannelBuffers(final String subscriptionPattern, final String channelName, 
			final String receivedMessage); void addMessageToChannelBuffer(final String channelName, final String msg); List<String> getLastMessages(String channelName, int msgCount); boolean isChannelPresent(String channelName); void createChannelQueue(final String channelName); void deleteChannelBuffer(final String channelName); void deleteAllChannelBuffers(); Set<String> getActiveChannelsList(); Set<String> getActiveChannelCodes(); @SuppressWarnings("unchecked") Boolean getChannelPublicStatus(String channelName); @SuppressWarnings("unchecked") Map<String, Boolean> getAllRunningCollections(); List<String> getLatestFromAllChannels(final int msgCount); String parseChannelName(String channelName); void close(); static final int NO_DATA_TIMEOUT; static final int CHECK_INTERVAL; static final int CHECK_CHANNEL_PUBLIC_INTERVAL; static String redisHost; static int redisPort; static JedisConnectionObject jedisConn; static Jedis subscriberJedis; static RedisSubscriber aidrSubscriber; static final String CHANNEL_PREFIX_STRING; static ConcurrentHashMap<String, ChannelBuffer> subscribedChannels; }