long start = System.currentTimeMillis();
List<DatabusSubscription> subs = null;
//parse source ids
SourceIdNameRegistry srcRegistry = _relay.getSourcesIdNameRegistry();
HashSet<Integer> sourceIds = new HashSet<Integer>();
if (null != sourcesListStr)
{
String[] sourcesList = sourcesListStr.split(",");
for (String sourceId: sourcesList)
{
try
{
Integer srcId = Integer.valueOf(sourceId);
sourceIds.add(srcId);
}
catch (NumberFormatException nfe)
{
HttpStatisticsCollector globalHttpStatsCollector = _relay.getHttpStatisticsCollector();
if (null != globalHttpStatsCollector) {
globalHttpStatsCollector.registerInvalidStreamRequest();
}
throw new InvalidRequestParamValueException(COMMAND_NAME, SOURCES_PARAM, sourceId);
}
}
}
//process explicit subscriptions and generate respective logical partition filters
NavigableSet<PhysicalPartitionKey> ppartKeys = null;
if (null != subsStr)
{
List<DatabusSubscription.Builder> subsBuilder = null;
subsBuilder = objMapper.readValue(subsStr,
new TypeReference<List<DatabusSubscription.Builder>>(){});
subs = new ArrayList<DatabusSubscription>(subsBuilder.size());
for (DatabusSubscription.Builder subBuilder: subsBuilder)
{
subs.add(subBuilder.build());
}
ppartKeys = new TreeSet<PhysicalPartitionKey>();
for (DatabusSubscription sub: subs)
{
PhysicalPartition ppart = sub.getPhysicalPartition();
if (ppart.isAnyPartitionWildcard())
{
ppartKeys = _eventBuffer.getAllPhysicalPartitionKeys(); break;
}
else
{
ppartKeys.add(new PhysicalPartitionKey(ppart));
}
}
}
// TODO
// The following if statement is a very conservative one just to make sure that there are
// not some clients out there that send subs, but do not send checkpoint mult. It seems that
// this was the case during development but never in production, so we should remove this
// pretty soon (1/28/2013).
// Need to make sure that we don't have tests that send requests in this form.
if(subs != null && checkpointStringMult == null && checkpointString != null) {
throw new RequestProcessingException("Both Subscriptions and CheckpointMult should be present");
}
//convert source ids into subscriptions
if (null == subs) subs = new ArrayList<DatabusSubscription>();
for (Integer srcId: sourceIds)
{
LogicalSource lsource = srcRegistry.getSource(srcId);
if(lsource == null)
throw new InvalidRequestParamValueException(COMMAND_NAME, SOURCES_PARAM, srcId.toString());
if(isDebug)
LOG.debug("registry returns " + lsource + " for srcid="+ srcId);
DatabusSubscription newSub = DatabusSubscription.createSimpleSourceSubscription(lsource);