Jian Li
Committed by Gerrit Code Review

Add skeletal CPMan manager component interfaces

Change-Id: Ica16e43849dd3bb0b90936a20ef4af477045b376
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.cpman;
/**
* Abstraction of control message.
*/
public interface ControlMessage {
enum Type {
INCOMING_PACKET, OUTGOING_PACKET, FLOW_MOD_PACKET,
FLOW_REMOVED_PACKET, REQUEST_PACKET, REPLY_PACKET
}
/**
* Returns the control message type.
*
* @return control message type
*/
Type type();
/**
* Returns the latest control message load.
*
* @return control message load
*/
long load();
/**
* Returns the latest control message rate.
*
* @return control message rate
*/
long rate();
/**
* Returns the latest control message packet count.
*
* @return packet count
*/
long count();
/**
* Returns the time that this control message stats collected.
*
* @return
*/
long timeStamp();
}
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.cpman;
/**
* Default control message implementation.
*/
public class DefaultControlMessage implements ControlMessage {
private final Type type;
private final long load;
private final long rate;
private final long count;
private final long timeStamp;
/**
* Generates a control message instance using given type and statistic
* information.
*
* @param type control message type
* @param load control message load
* @param rate control message rate
* @param count control message count
* @param timeStamp time stamp of the control message stats
*/
public DefaultControlMessage(Type type, long load, long rate,
long count, long timeStamp) {
this.type = type;
this.load = load;
this.rate = rate;
this.count = count;
this.timeStamp = timeStamp;
}
@Override
public Type type() {
return type;
}
@Override
public long load() {
return load;
}
@Override
public long rate() {
return rate;
}
@Override
public long count() {
return count;
}
@Override
public long timeStamp() {
return timeStamp;
}
}
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.cpman.message;
/**
* Service for administering the control message monitoring.
*/
public interface ControlMessageAdminService extends ControlMessageService {
}
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.cpman.message;
import org.onosproject.event.AbstractEvent;
import org.onosproject.cpman.ControlMessage;
import static com.google.common.base.MoreObjects.toStringHelper;
/**
* Describes control message event.
*/
public class ControlMessageEvent
extends AbstractEvent<ControlMessageEvent.Type, ControlMessage> {
/**
* Type of control message events.
*/
public enum Type {
/**
* signifies that the control message stats has been updated.
*/
STATS_UPDATE
}
/**
* Creates an event of given type and the current time.
*
* @param type control message event type
* @param controlMessage event control message subject
*/
public ControlMessageEvent(Type type, ControlMessage controlMessage) {
super(type, controlMessage);
}
@Override
public String toString() {
return toStringHelper(this)
.add("type", type())
.add("subject", subject())
.toString();
}
}
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.cpman.message;
import org.onosproject.event.EventListener;
/**
* Entity capable of receiving control message related event.
*/
public interface ControlMessageListener extends EventListener<ControlMessageEvent> {
}
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.cpman.message;
import org.onosproject.net.provider.Provider;
/**
* Abstraction of a control message provider.
*/
public interface ControlMessageProvider extends Provider {
}
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.cpman.message;
import org.onosproject.net.provider.ProviderRegistry;
/**
* Abstraction of a control message provider registry.
*/
public interface ControlMessageProviderRegistry
extends ProviderRegistry<ControlMessageProvider,
ControlMessageProviderService> {
}
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.cpman.message;
import org.onosproject.cpman.ControlMessage;
import org.onosproject.net.DeviceId;
import org.onosproject.net.provider.ProviderService;
import java.util.Collection;
/**
* Service through which control message providers can inject control message
* stats into the core.
*/
public interface ControlMessageProviderService
extends ProviderService<ControlMessageProvider> {
/**
* Used to notify the core about the control message statistic information.
*
* @param deviceId device identifier
* @param controlMessages a collection of control message stats
*/
void updateStatsInfo(DeviceId deviceId, Collection<ControlMessage> controlMessages);
}
\ No newline at end of file
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.cpman.message;
import org.onosproject.event.ListenerService;
/**
* Service for obtaining control message statistic information.
*/
public interface ControlMessageService extends ListenerService {
}
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.cpman.message;
import org.onosproject.cpman.ControlMessage;
import org.onosproject.net.DeviceId;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.store.Store;
import java.util.Collection;
/**
* Manages inventory of control message.
*/
public interface ControlMessageStore
extends Store<ControlMessageEvent, ControlMessageStoreDelegate> {
/**
* Updates the control message statistics of the specified device.
*
* @param providerId provider identifier
* @param deviceId device identifier
* @param controlMessages a collection of control message stats
* @return ready to send event describing what occurred
*/
ControlMessageEvent updateStatsInfo(ProviderId providerId,
DeviceId deviceId,
Collection<ControlMessage> controlMessages);
}
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.cpman.message;
import org.onosproject.store.StoreDelegate;
/**
* Control message store delegate abstraction.
*/
public interface ControlMessageStoreDelegate extends StoreDelegate<ControlMessageEvent> {
}
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Service for looking up control message stats.
*/
package org.onosproject.cpman.message;
\ No newline at end of file