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