X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fadsal%2Fhosttracker_new%2Fimplementation%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fhosttracker%2Finternal%2FDefaultEntityClassifier.java;fp=opendaylight%2Fadsal%2Fhosttracker_new%2Fimplementation%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fhosttracker%2Finternal%2FDefaultEntityClassifier.java;h=39c322fdef45fd8460f1749016d39e17a817fcd4;hb=42c32160bfd41de57189bb246fec5ffb48ed8e9e;hp=0000000000000000000000000000000000000000;hpb=edf5bfcee83c750853253ccfd991ba7000f5f65b;p=controller.git diff --git a/opendaylight/adsal/hosttracker_new/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/DefaultEntityClassifier.java b/opendaylight/adsal/hosttracker_new/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/DefaultEntityClassifier.java new file mode 100644 index 0000000000..39c322fdef --- /dev/null +++ b/opendaylight/adsal/hosttracker_new/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/DefaultEntityClassifier.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2011,2012 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/legal/epl-v10.html + * + * 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. + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Originally created by David Erickson, Stanford University + * + * 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.opendaylight.controller.hosttracker.internal; + +import java.util.Collection; +import java.util.EnumSet; + +import org.opendaylight.controller.hosttracker.Entity; +import org.opendaylight.controller.hosttracker.IDevice; +import org.opendaylight.controller.hosttracker.IDeviceService; +import org.opendaylight.controller.hosttracker.IDeviceService.DeviceField; +import org.opendaylight.controller.hosttracker.IEntityClass; +import org.opendaylight.controller.hosttracker.IEntityClassListener; +import org.opendaylight.controller.hosttracker.IEntityClassifierService; + +/** + * This is a default entity classifier that simply classifies all entities into + * a fixed entity class, with key fields of MAC and VLAN. + * + * @author readams + */ +public class DefaultEntityClassifier implements IEntityClassifierService { + /** + * A default fixed entity class + */ + protected static class DefaultEntityClass implements IEntityClass { + String name; + + public DefaultEntityClass(String name) { + this.name = name; + } + + @Override + public EnumSet getKeyFields() { + return keyFields; + } + + @Override + public String getName() { + return name; + } + } + + protected static EnumSet keyFields; + static { + keyFields = EnumSet.of(DeviceField.MAC, DeviceField.VLAN); + } + protected static DefaultEntityClass entityClass = new DefaultEntityClass( + "DefaultEntityClass"); + + @Override + public IEntityClass classifyEntity(Entity entity) { + return entityClass; + } + + @Override + public IEntityClass reclassifyEntity(IDevice curDevice, Entity entity) { + return entityClass; + } + + @Override + public void deviceUpdate(IDevice oldDevice, + Collection newDevices) { + // no-op + } + + @Override + public EnumSet getKeyFields() { + return keyFields; + } + + @Override + public void addListener(IEntityClassListener listener) { + // no-op + + } +}