1 /*******************************************************************************
2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ============LICENSE_END=========================================================
19 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21 *******************************************************************************/
22 package org.onap.dmaap.dmf.mr.backends.memory;
24 import org.onap.dmaap.dmf.mr.CambriaApiException;
25 import org.onap.dmaap.dmf.mr.backends.Consumer;
26 import org.onap.dmaap.dmf.mr.backends.ConsumerFactory;
28 import java.util.ArrayList;
29 import java.util.Collection;
30 import java.util.HashMap;
34 * @author anowarul.islam
37 public class MemoryConsumerFactory implements ConsumerFactory
40 private final MemoryQueue fQueue;
44 * Initializing constructor
47 public MemoryConsumerFactory ( MemoryQueue q )
55 * @param consumerGroupId
61 public Consumer getConsumerFor ( String topic, String consumerGroupId, String clientId, int timeoutMs, String remotehost )
63 return new MemoryConsumer ( topic, consumerGroupId );
68 * Define nested inner class
71 private class MemoryConsumer implements Consumer
74 private final String fTopic;
75 private final String fConsumer;
76 private final long fCreateMs;
77 private long fLastAccessMs;
81 * Initializing MemoryConsumer constructor
86 public MemoryConsumer ( String topic, String consumer )
90 fCreateMs = System.currentTimeMillis ();
91 fLastAccessMs = fCreateMs;
97 * return consumer details
99 public Message nextMessage ()
101 return fQueue.get ( fTopic, fConsumer );
105 public boolean close() {
106 //Nothing to close/clean up.
112 public void commitOffsets()
114 // ignoring this aspect
119 public long getOffset()
126 * get consumer topic name
128 public String getName ()
130 return fTopic + "/" + fConsumer;
134 public long getCreateTimeMs ()
140 public long getLastAccessMs ()
142 return fLastAccessMs;
148 public void setOffset(long offset) {
149 // TODO Auto-generated method stub
157 public void destroyConsumer(String topic, String consumerGroupId,
159 //No cache for memory consumers, so NOOP
163 public void dropCache ()
165 // nothing to do - there's no cache here
170 * @return ArrayList<MemoryConsumer>
172 public Collection<? extends Consumer> getConsumers ()
174 return new ArrayList<> ();
178 public HashMap getConsumerForKafka011(String topic, String consumerGroupName, String consumerId, int timeoutMs,
179 String remotehost) throws UnavailableException, CambriaApiException {
180 // TODO Auto-generated method stub