2 * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.openflowjava.protocol.impl.core.connection;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.cache.Cache;
13 import java.util.concurrent.TimeoutException;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
18 final class ResponseExpectedRpcListener<T extends OfHeader> extends AbstractRpcListener<T> {
19 private static final Logger LOG = LoggerFactory.getLogger(ResponseExpectedRpcListener.class);
20 private final Cache<RpcResponseKey, ResponseExpectedRpcListener<?>> cache;
21 private final RpcResponseKey key;
23 ResponseExpectedRpcListener(final Object message, final String failureInfo,
24 final Cache<RpcResponseKey, ResponseExpectedRpcListener<?>> cache, final RpcResponseKey key) {
25 super(message, failureInfo);
26 this.cache = requireNonNull(cache);
27 this.key = requireNonNull(key);
30 public void discard() {
31 LOG.warn("Request for {} did not receive a response", key);
32 failedRpc(new TimeoutException("Request timed out"));
35 @SuppressWarnings("unchecked")
36 public void completed(final OfHeader message) {
37 successfulRpc((T)message);
41 protected void operationSuccessful() {
42 LOG.debug("Request for {} sent successfully", key);