2 * Copyright (c) 2013 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
9 package org.opendaylight.openflowjava.protocol.impl.clients;
11 import java.util.Arrays;
13 import org.opendaylight.openflowjava.util.ByteBufUtils;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
18 * Class representing waiting on message
19 * @author michal.polkorab
21 public class WaitForMessageEvent implements ClientEvent {
23 private static final Logger LOGGER = LoggerFactory.getLogger(WaitForMessageEvent.class);
24 private byte[] headerExpected;
25 private byte[] headerReceived;
28 * @param headerExpected header (first 8 bytes) of expected message
30 public WaitForMessageEvent(byte[] headerExpected) {
31 this.headerExpected = new byte[headerExpected.length];
32 for (int i = 0; i < headerExpected.length; i++) {
33 this.headerExpected[i] = headerExpected[i];
38 public boolean eventExecuted() {
39 if (headerReceived == null) {
42 if (!Arrays.equals(headerExpected, headerReceived)) {
43 if (LOGGER.isDebugEnabled()) {
44 LOGGER.debug("expected msg: {}", ByteBufUtils.bytesToHexString(headerExpected));
45 LOGGER.debug("received msg: {}", ByteBufUtils.bytesToHexString(headerReceived));
49 LOGGER.debug("Headers OK");
54 * @param headerReceived header (first 8 bytes) of expected message
56 public void setHeaderReceived(byte[] headerReceived) {
57 this.headerReceived = new byte[headerReceived.length];
58 for (int i = 0; i < headerReceived.length; i++) {
59 this.headerReceived[i] = headerReceived[i];