package org.opendaylight.lispflowmapping.interfaces.dao;
import java.util.Map;
-import java.util.concurrent.TimeUnit;
-public interface ILispDAO extends IQueryAll {
+public interface ILispDAO {
/**
* Put a entry into the DAO.
* The key.
* @return The value from the DAO.
*/
- public <K> Map<String, Object> get(K key);
+ public Map<String, Object> get(Object key);
/**
- * Remove an entry from the DAO
+ * Enumerate all the entries from the DAO
*
- * @param key
- * The key of the entry
- * @return true if success, false otherwise
+ * @param visitor
+ */
+ public void getAll(IRowVisitor visitor);
+
+ /**
+ * Remove an entry from the DAO
*/
- public boolean remove(Object key);
+ public void remove(Object key);
/**
* Remove an entry from the DAO
* The key of the entry
* @param valueKey
* The value to delete
- * @return true if success, false otherwise
*/
- public boolean removeSpecific(Object key, String valueKey);
+ public void removeSpecific(Object key, String valueKey);
/**
* Clear the DAO and remove all of the entries.
*/
- public void clearAll();
-
- /**
- * @return The time unit of the DAO cleaner
- */
- public TimeUnit getTimeUnit();
-
- /**
- * Set the time unit of the DAO cleaner
- *
- * @param timeUnit
- */
- public void setTimeUnit(TimeUnit timeUnit);
+ public void removeAll();
}
+++ /dev/null
-/*
- * Copyright (c) 2014 Contextream, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.lispflowmapping.interfaces.dao;
-
-/**
- * An interface for allowing iteration over all of the entries in the DAO
- */
-public interface IQueryAll {
- public void getAll(IRowVisitor visitor);
-}
void setShouldAuthenticate(boolean shouldAuthenticate);
- public void setOverwrite(boolean overwrite);
+ void setOverwrite(boolean overwrite);
/**
* This method removes the given authentication key from the map server.
* @param maskLen
* @return
*/
- boolean removeAuthenticationKey(LispAddressContainer address, int maskLen);
+ void removeAuthenticationKey(LispAddressContainer address, int maskLen);
/**
* This method adds an authentication key to the address.
* @param key
* @return
*/
- boolean addAuthenticationKey(LispAddressContainer address, int maskLen, String key);
+ void addAuthenticationKey(LispAddressContainer address, int maskLen, String key);
}
import org.opendaylight.controller.clustering.services.IClusterContainerServices;
import org.opendaylight.controller.clustering.services.IClusterServices;
import org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO;
-import org.opendaylight.lispflowmapping.interfaces.dao.IQueryAll;
import org.opendaylight.lispflowmapping.interfaces.dao.IRowVisitor;
import org.opendaylight.lispflowmapping.interfaces.dao.MappingEntry;
import org.opendaylight.lispflowmapping.interfaces.dao.MappingServiceRLOCGroup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ClusterDAOService implements ILispDAO, IQueryAll {
+public class ClusterDAOService implements ILispDAO {
protected static final Logger logger = LoggerFactory.getLogger(ClusterDAOService.class);
private IClusterContainerServices clusterContainerService = null;
scheduler.shutdownNow();
}
- @SuppressWarnings("deprecation")
private void allocateCache() {
if (this.clusterContainerService == null) {
logger.warn("un-initialized clusterContainerService, can't create cache");
logger.trace("Cache successfully created for ClusterDAOService");
}
- @SuppressWarnings({ "unchecked", "deprecation" })
+ @SuppressWarnings({ "unchecked" })
private void retrieveCache() {
if (this.clusterContainerService == null) {
logger.warn("un-initialized clusterContainerService, can't retrieve cache");
return keyToValues.get(valueKey);
}
- public <K> Map<String, Object> get(K key) {
+ public Map<String, Object> get(Object key) {
return data.get(key);
}
- public boolean remove(Object key) {
- return data.remove(key) != null;
+ public void remove(Object key) {
+ data.remove(key);
}
- public boolean removeSpecific(Object key, String valueKey) {
- if (!data.containsKey(key) || !data.get(key).containsKey(valueKey)) {
- return false;
+ public void removeSpecific(Object key, String valueKey) {
+ if (data.containsKey(key) && data.get(key).containsKey(valueKey)) {
+ data.get(key).remove(valueKey);
}
- return data.get(key).remove(valueKey) != null;
}
- public void clearAll() {
+ public void removeAll() {
data.clear();
}
import org.opendaylight.lispflowmapping.implementation.util.LispNotificationHelper;
import org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO;
import org.opendaylight.lispflowmapping.interfaces.dao.ILispTypeConverter;
-import org.opendaylight.lispflowmapping.interfaces.dao.IQueryAll;
import org.opendaylight.lispflowmapping.interfaces.dao.IRowVisitor;
import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
import org.opendaylight.lispflowmapping.interfaces.lisp.IMapNotifyHandler;
public void _dumpAll(final CommandInterpreter ci) {
ci.println("EID\tRLOCs");
- if (lispDao instanceof IQueryAll) {
- ((IQueryAll) lispDao).getAll(new IRowVisitor() {
- String lastKey = "";
-
- public void visitRow(Object keyId, String valueKey, Object value) {
- String key = keyId.getClass().getSimpleName() + "#" + keyId;
- if (!lastKey.equals(key)) {
- ci.println();
- ci.print(key + "\t");
- }
- ci.print(valueKey + "=" + value + "\t");
- lastKey = key;
+ lispDao.getAll(new IRowVisitor() {
+ String lastKey = "";
+
+ public void visitRow(Object keyId, String valueKey, Object value) {
+ String key = keyId.getClass().getSimpleName() + "#" + keyId;
+ if (!lastKey.equals(key)) {
+ ci.println();
+ ci.print(key + "\t");
}
- });
- ci.println();
- } else {
- ci.println("Not implemented by this DAO");
- }
+ ci.print(valueKey + "=" + value + "\t");
+ lastKey = key;
+ }
+ });
+ ci.println();
return;
}
return mapServer.getAuthenticationKey(address, maskLen);
}
- public boolean removeAuthenticationKey(LispAddressContainer address, int maskLen) {
- return mapServer.removeAuthenticationKey(address, maskLen);
+ public void removeAuthenticationKey(LispAddressContainer address, int maskLen) {
+ mapServer.removeAuthenticationKey(address, maskLen);
}
- public boolean addAuthenticationKey(LispAddressContainer address, int maskLen, String key) {
- return mapServer.addAuthenticationKey(address, maskLen, key);
+ public void addAuthenticationKey(LispAddressContainer address, int maskLen, String key) {
+ mapServer.addAuthenticationKey(address, maskLen, key);
}
public boolean shouldIterateMask() {
@Override
public void clean() {
- lispDao.clearAll();
+ lispDao.removeAll();
}
@Override
return getPassword(address, maskLen);
}
- public boolean removeAuthenticationKey(LispAddressContainer address, int maskLen) {
+ public void removeAuthenticationKey(LispAddressContainer address, int maskLen) {
IMappingServiceKey key = MappingServiceKeyUtil.generateMappingServiceKey(address, maskLen);
dao.removeSpecific(key, PASSWORD_SUBKEY);
- return true;
}
- public boolean addAuthenticationKey(LispAddressContainer address, int maskLen, String key) {
+ public void addAuthenticationKey(LispAddressContainer address, int maskLen, String key) {
IMappingServiceKey mappingServiceKey = MappingServiceKeyUtil.generateMappingServiceKey(address, maskLen);
dao.put(mappingServiceKey, new MappingEntry<String>(PASSWORD_SUBKEY, key));
- return true;
}
public boolean shouldOverwrite() {
assertEquals(mapNotify, null);
}
+ @SuppressWarnings("unchecked")
@Test
public void handleAddAuthenticationKey() throws Exception {
String password = "pass";
IMappingServiceKey key = getDefualtKey();
oneOf(lispDAO).put(weq(key),
weq((MappingEntry<String>[]) (Arrays.asList(new MappingEntry<String>(AbstractLispComponent.PASSWORD_SUBKEY, password)).toArray())));
- assertEquals(true, testedMapServer.addAuthenticationKey(LispAFIConvertor.toContainer(eid), key.getMask(), password));
+ testedMapServer.addAuthenticationKey(LispAFIConvertor.toContainer(eid), key.getMask(), password);
}
@Test
public void handleRemoveAuthenticationKey() throws Exception {
IMappingServiceKey key = getDefualtKey();
oneOf(lispDAO).removeSpecific(weq(key), with(AbstractLispComponent.PASSWORD_SUBKEY));
- assertEquals(true, testedMapServer.removeAuthenticationKey(LispAFIConvertor.toContainer(eid), key.getMask()));
+ testedMapServer.removeAuthenticationKey(LispAFIConvertor.toContainer(eid), key.getMask());
}
private void addDefaultPutAndGetExpectations(LispAFIAddress addr, int mask) {
import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lcaftrafficengineeringaddress.Hops;
import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lcaftrafficengineeringaddress.HopsBuilder;
import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lispaddress.LispAddressContainer;
-import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lispaddress.LispAddressContainerBuilder;
import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lispaddress.lispaddresscontainer.address.Ipv4;
import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lispaddress.lispaddresscontainer.address.Ipv4Builder;
import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lispaddress.lispaddresscontainer.address.LcafApplicationDataBuilder;
public static final String ODL = "org.opendaylight.controller";
public static final String YANG = "org.opendaylight.yangtools";
public static final String JERSEY = "com.sun.jersey";
- private static final String DEBUG_PORT = "8005";
private static final int MAX_SERVICE_LOAD_RETRIES = 45;
@After
sendMapRegister(mapRegister.build());
- // this will fail if no MapNotify arrives for 6 seconds
- MapNotify notify = receiveMapNotify();
+ assertMapNotifyRecieved();
}
public void testPasswordMaskMatch() throws Exception {
sendMapRegister(mapRegister.build());
- // this will fail if no MapNotify arrives for 6 seconds
- MapNotify notify = receiveMapNotify();
+ assertMapNotifyRecieved();
etlr.setLispAddressContainer(LispAFIConvertor.toContainer(addressOutOfRange));
mapRegister
private void registerForTTL(LispIpv4Address eid) throws SocketTimeoutException {
MapRegister mapRegister = createMapRegister(eid);
sendMapRegister(mapRegister);
- receiveMapNotify();
+ assertMapNotifyRecieved();
}
private void testTTLBeforeRegister(MapRequest mapRequest) throws SocketTimeoutException {
LispAFIConvertor.toContainer(LispAFIConvertor.asIPAfiAddress(rloc))).build();
mr.getEidToLocatorRecord().get(0).getLocatorRecord().set(0, record);
sendMapRegister(mr);
- receiveMapNotify();
+ assertMapNotifyRecieved();
MapRequest mapRequest = createMapRequest(LispAFIConvertor.asIPAfiAddress(eid));
MapRequestBuilder builder = new MapRequestBuilder(mapRequest);
builder.setPitr(true);
}
+ private void assertMapNotifyRecieved() throws SocketTimeoutException {
+ receiveMapNotify();
+ }
+
private MapReply receiveMapReply() throws SocketTimeoutException {
return MapReplySerializer.getInstance().deserialize(ByteBuffer.wrap(receivePacket().getData()));
}
}
}
+ @SuppressWarnings({ "rawtypes", "unchecked" })
private void areWeReady() throws InvalidSyntaxException {
assertNotNull(bc);
boolean debugit = false;
}
}
- private LispAddressContainer getIPContainer(String ip) {
- return new LispAddressContainerBuilder().setAddress(asIPAfiAddress(ip)).build();
- }
-
private Ipv4 asIPAfiAddress(String ip) {
return new Ipv4Builder().setIpv4Address(new Ipv4Address(ip)).setAfi((short) AddressFamilyNumberEnum.IP.getIanaCode()).build();
}
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.core.Response;
+import javax.ws.rs.core.SecurityContext;
import org.codehaus.enunciate.jaxrs.ResponseCode;
import org.codehaus.enunciate.jaxrs.StatusCodes;
import org.opendaylight.controller.containermanager.IContainerManager;
import org.opendaylight.controller.northbound.commons.RestMessages;
import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
+import org.opendaylight.controller.northbound.commons.exception.InternalServerErrorException;
import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
-import org.opendaylight.controller.northbound.commons.exception.InternalServerErrorException;
import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
import org.opendaylight.controller.sal.authorization.Privilege;
import org.opendaylight.controller.sal.utils.ServiceHelper;
import org.opendaylight.lispflowmapping.type.AddressFamilyNumberEnum;
import org.opendaylight.lispflowmapping.type.LispCanonicalAddressFormatEnum;
import org.opendaylight.lispflowmapping.type.lisp.EidRecord;
-import org.opendaylight.lispflowmapping.type.lisp.LocatorRecord;
-import org.opendaylight.lispflowmapping.type.lisp.MapRegister;
import org.opendaylight.lispflowmapping.type.lisp.MapRequest;
import org.opendaylight.lispflowmapping.type.lisp.address.LispAddress;
import org.opendaylight.lispflowmapping.type.lisp.address.LispAddressGeneric;
throw new InternalServerErrorException(RestMessages.INTERNALERROR.toString() + " : There was an error looking up the EID");
}
- EidToLocatorRecord record = null;
-
- record = mapReply.getEidToLocatorRecord().get(0);
-
- return record;
+ return mapReply.getEidToLocatorRecord().get(0);
}
private void keyCheck(IFlowMapping mappingService, MapRegisterNB mapRegisterNB) {
ILispmappingNorthbound nbService = (ILispmappingNorthbound) ServiceHelper.getInstance(ILispmappingNorthbound.class, containerName, this);
try {
- keyCheck(nbService.getMappingService(), mapRegisterNB);
+ keyCheck(nbService.getMappingService(), mapRegisterNB);
LispAddressConvertorNB.convertGenericToLispAddresses(mapRegisterNB.getMapRegister());
} catch (Exception e) {
}
ILispmappingNorthbound nbService = (ILispmappingNorthbound) ServiceHelper.getInstance(ILispmappingNorthbound.class, containerName, this);
- boolean success = false;
-
try {
- success = nbService.getMappingService().addAuthenticationKey(YangTransformerNB.transformLispAddress(lispAddress),
- authKeyNB.getMaskLength(), authKeyNB.getKey());
+ nbService.getMappingService().addAuthenticationKey(YangTransformerNB.transformLispAddress(lispAddress), authKeyNB.getMaskLength(),
+ authKeyNB.getKey());
} catch (Exception e) {
throw new InternalServerErrorException(RestMessages.INTERNALERROR.toString() + " : There was an error while adding the key");
}
- if (!success) {
- throw new InternalServerErrorException(RestMessages.INTERNALERROR.toString() + " : There was an error while adding the key");
- }
return Response.status(Response.Status.OK).build();
}
ILispmappingNorthbound nbService = (ILispmappingNorthbound) ServiceHelper.getInstance(ILispmappingNorthbound.class, containerName, this);
- boolean success = false;
try {
- success = nbService.getMappingService().removeAuthenticationKey(YangTransformerNB.transformLispAddress(lispAddress), mask);
+ nbService.getMappingService().removeAuthenticationKey(YangTransformerNB.transformLispAddress(lispAddress), mask);
} catch (Exception e) {
throw new InternalServerErrorException(RestMessages.INTERNALERROR.toString() + " : There was an error while deleting the key");
}
- if (!success) {
- throw new InternalServerErrorException(RestMessages.INTERNALERROR.toString() + " : There was an error while deleting the key");
- }
-
return Response.status(Response.Status.OK).build();
}
int mask = 0; // Not used here
- boolean success = false;
try {
- success = nbService.getMappingService().removeAuthenticationKey(YangTransformerNB.transformLispAddress(lispAddress), mask);
+ nbService.getMappingService().removeAuthenticationKey(YangTransformerNB.transformLispAddress(lispAddress), mask);
} catch (Exception e) {
throw new InternalServerErrorException(RestMessages.INTERNALERROR.toString() + " : There was an error while deleting the key");
}
- if (!success) {
- throw new InternalServerErrorException(RestMessages.INTERNALERROR.toString() + " : There was an error while deleting the key");
- }
-
return Response.status(Response.Status.OK).build();
}
/META-INF
/target
/target
+/target
+/target
+/target
+/target