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 java.util.concurrent.TimeoutException;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
16 import com.google.common.base.Preconditions;
17 import com.google.common.cache.Cache;
19 final class ResponseExpectedRpcListener<T extends OfHeader> extends AbstractRpcListener<T> {
20 private static final Logger LOG = LoggerFactory.getLogger(ResponseExpectedRpcListener.class);
21 private final Cache<RpcResponseKey, ResponseExpectedRpcListener<?>> cache;
22 private final RpcResponseKey key;
24 ResponseExpectedRpcListener(final Object message, final String failureInfo,
25 final Cache<RpcResponseKey, ResponseExpectedRpcListener<?>> cache, final RpcResponseKey key) {
26 super(message, failureInfo);
27 this.cache = Preconditions.checkNotNull(cache);
28 this.key = Preconditions.checkNotNull(key);
31 public void discard() {
32 LOG.warn("Request for {} did not receive a response", key);
33 failedRpc(new TimeoutException("Request timed out"));
36 @SuppressWarnings("unchecked")
37 public void completed(final OfHeader message) {
38 successfulRpc((T)message);
42 protected void operationSuccessful() {
43 LOG.debug("Request for {} sent successfully", key);