Merge "Improve flow collection"
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / services / multilayer / MultiLayerFlowMultipartRequestOnTheFlyCallback.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.openflowplugin.impl.services.multilayer;
10
11 import java.util.List;
12 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
13 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
14 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
15 import org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProvider;
16 import org.opendaylight.openflowplugin.impl.services.AbstractMultipartRequestOnTheFlyCallback;
17 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
21
22 public class MultiLayerFlowMultipartRequestOnTheFlyCallback<T extends OfHeader> extends AbstractMultipartRequestOnTheFlyCallback<T> {
23
24     public MultiLayerFlowMultipartRequestOnTheFlyCallback(final RequestContext<List<T>> context,
25                                                           final Class<?> requestType,
26                                                           final DeviceContext deviceContext,
27                                                           final EventIdentifier eventIdentifier,
28                                                           final MultipartWriterProvider statisticsWriterProvider,
29                                                           final ConvertorExecutor convertorExecutor) {
30         super(context, requestType, deviceContext, eventIdentifier, statisticsWriterProvider, convertorExecutor);
31     }
32
33     @Override
34     protected boolean isMultipart(OfHeader result) {
35         return result instanceof MultipartReply
36             && MultipartReply.class.cast(result).getType().equals(getMultipartType());
37     }
38
39     @Override
40     protected boolean isReqMore(T result) {
41         return MultipartReply.class.cast(result).getFlags().isOFPMPFREQMORE();
42     }
43
44     @Override
45     protected MultipartType getMultipartType() {
46         return MultipartType.OFPMPFLOW;
47     }
48
49 }