cfgdef tool modifications to catch variable names that don't match properties

- catch errors in the cfgdef tool and abort compilation if a mismatch
  is seen
- Fix mismatches in the code discovered by the tool

Change-Id: Icd9a15eb9312bba6c2208b0b2a684062fcdc19c3
This commit is contained in:
Ray Milkey 2019-03-19 14:22:02 -07:00
parent 03e1eb36e4
commit ea3abd4ff6
14 changed files with 47 additions and 52 deletions

View File

@ -123,7 +123,6 @@ import static org.onosproject.net.flowobjective.Objective.Operation.REMOVE;
@Component(
service = { DhcpHandler.class, HostProvider.class },
property = {
"version:Integer = 4",
LEARN_ROUTE_FROM_LEASE_QUERY + ":Boolean=" + LEARN_ROUTE_FROM_LEASE_QUERY_DEFAULT
}
)

View File

@ -128,7 +128,6 @@ import java.util.concurrent.Semaphore;
@Component(
service = { DhcpHandler.class, HostProvider.class },
property = {
"version:Integer=6",
LEARN_ROUTE_FROM_LEASE_QUERY + ":Boolean=" + LEARN_ROUTE_FROM_LEASE_QUERY_DEFAULT
}
)

View File

@ -45,10 +45,7 @@ import static org.slf4j.LoggerFactory.getLogger;
*/
@Component(
immediate = true,
service = DhcpFpmPrefixStore.class,
property = {
"fpm_type=DHCP"
}
service = DhcpFpmPrefixStore.class
)
public class DistributedFpmPrefixStore implements DhcpFpmPrefixStore {

View File

@ -219,7 +219,7 @@ public class ReactiveForwarding {
private boolean matchIcmpFields = MATCH_ICMP_FIELDS_DEFAULT;
/** Ignore (do not forward) IPv4 multicast packets; default is false. */
private boolean ignoreIpv4McastPackets = IGNORE_IPV4_MCAST_PACKETS_DEFAULT;
private boolean ignoreIPv4Multicast = IGNORE_IPV4_MCAST_PACKETS_DEFAULT;
/** Enable record metrics for reactive forwarding. */
private boolean recordMetrics = RECORD_METRICS_DEFAULT;
@ -436,11 +436,11 @@ public class ReactiveForwarding {
Tools.isPropertyEnabled(properties, IGNORE_IPV4_MCAST_PACKETS);
if (ignoreIpv4McastPacketsEnabled == null) {
log.info("Ignore IPv4 multi-cast packet is not configured, " +
"using current value of {}", ignoreIpv4McastPackets);
"using current value of {}", ignoreIPv4Multicast);
} else {
ignoreIpv4McastPackets = ignoreIpv4McastPacketsEnabled;
ignoreIPv4Multicast = ignoreIpv4McastPacketsEnabled;
log.info("Configured. Ignore IPv4 multicast packets is {}",
ignoreIpv4McastPackets ? "enabled" : "disabled");
ignoreIPv4Multicast ? "enabled" : "disabled");
}
Boolean recordMetricsEnabled =
Tools.isPropertyEnabled(properties, RECORD_METRICS);
@ -507,7 +507,7 @@ public class ReactiveForwarding {
}
// Do not process IPv4 multicast packets, let mfwd handle them
if (ignoreIpv4McastPackets && ethPkt.getEtherType() == Ethernet.TYPE_IPV4) {
if (ignoreIPv4Multicast && ethPkt.getEtherType() == Ethernet.TYPE_IPV4) {
if (id.mac().isMulticast()) {
return;
}

View File

@ -66,7 +66,7 @@ import static org.slf4j.LoggerFactory.getLogger;
immediate = true,
service = TransactionPerfApp.class,
property = {
MAP_NAME_DEFAULT + "=" + MAP_NAME,
MAP_NAME + "=" + MAP_NAME_DEFAULT,
READ_PERCENTAGE + ":Double=" + READ_PERCENTAGE_DEFAULT,
TOTAL_OPERATIONS + ":Integer=" + TOTAL_OPERATIONS_DEFAULT,
WITH_CONTENTION + ":Boolean=" + WITH_CONTENTION_DEFAULT,

View File

@ -134,7 +134,7 @@ public class DistributedVirtualFlowRuleStore
= new MessageSubject("virtual-peer-apply-completed");
/** Number of threads in the message handler pool. */
private int msgHandlerThreadPoolSize = MESSAGE_HANDLER_THREAD_POOL_SIZE_DEFAULT;
private int messageHandlerThreadPoolSize = MESSAGE_HANDLER_THREAD_POOL_SIZE_DEFAULT;
/** Delay in ms between successive backup runs. */
private int backupPeriod = BACKUP_PERIOD_MILLIS_DEFAULT;
@ -197,7 +197,7 @@ public class DistributedVirtualFlowRuleStore
eventHandler = Executors.newSingleThreadExecutor(
groupedThreads("onos/virtual-flow", "event-handler", log));
messageHandlingExecutor = Executors.newFixedThreadPool(
msgHandlerThreadPoolSize, groupedThreads("onos/store/virtual-flow", "message-handlers", log));
messageHandlerThreadPoolSize, groupedThreads("onos/store/virtual-flow", "message-handlers", log));
registerMessageHandlers(messageHandlingExecutor);
@ -238,7 +238,7 @@ public class DistributedVirtualFlowRuleStore
int newBackupPeriod;
try {
String s = get(properties, MESSAGE_HANDLER_THREAD_POOL_SIZE);
newPoolSize = isNullOrEmpty(s) ? msgHandlerThreadPoolSize : Integer.parseInt(s.trim());
newPoolSize = isNullOrEmpty(s) ? messageHandlerThreadPoolSize : Integer.parseInt(s.trim());
s = get(properties, BACKUP_PERIOD_MILLIS);
newBackupPeriod = isNullOrEmpty(s) ? backupPeriod : Integer.parseInt(s.trim());
@ -256,11 +256,11 @@ public class DistributedVirtualFlowRuleStore
if (restartBackupTask) {
log.warn("Currently, backup tasks are not supported.");
}
if (newPoolSize != msgHandlerThreadPoolSize) {
msgHandlerThreadPoolSize = newPoolSize;
if (newPoolSize != messageHandlerThreadPoolSize) {
messageHandlerThreadPoolSize = newPoolSize;
ExecutorService oldMsgHandler = messageHandlingExecutor;
messageHandlingExecutor = Executors.newFixedThreadPool(
msgHandlerThreadPoolSize, groupedThreads("onos/store/virtual-flow", "message-handlers", log));
messageHandlerThreadPoolSize, groupedThreads("onos/store/virtual-flow", "message-handlers", log));
// replace previously registered handlers.
registerMessageHandlers(messageHandlingExecutor);
@ -566,7 +566,7 @@ public class DistributedVirtualFlowRuleStore
private void logConfig(String prefix) {
log.info("{} with msgHandlerPoolSize = {}; backupPeriod = {}",
prefix, msgHandlerThreadPoolSize, backupPeriod);
prefix, messageHandlerThreadPoolSize, backupPeriod);
}
private void storeBatchInternal(NetworkId networkId, FlowRuleBatchOperation operation) {

View File

@ -97,7 +97,7 @@ public class CoreManager implements CoreService {
private int maxEventTimeLimit = MAX_EVENT_TIME_LIMIT_DEFAULT;
/** Enable queue performance check on shared pool. */
private boolean calculatePoolPerformance = CALCULATE_PERFORMANCE_CHECK_DEFAULT;
private boolean sharedThreadPerformanceCheck = CALCULATE_PERFORMANCE_CHECK_DEFAULT;
@Activate
@ -184,11 +184,11 @@ public class CoreManager implements CoreService {
Boolean performanceCheck = Tools.isPropertyEnabled(properties, CALCULATE_PERFORMANCE_CHECK);
if (performanceCheck != null) {
calculatePoolPerformance = performanceCheck;
SharedExecutors.setMetricsService(calculatePoolPerformance ? metricsService : null);
sharedThreadPerformanceCheck = performanceCheck;
SharedExecutors.setMetricsService(sharedThreadPerformanceCheck ? metricsService : null);
}
log.info("Settings: sharedThreadPoolSize={}, maxEventTimeLimit={}, calculatePoolPerformance={}",
sharedThreadPoolSize, maxEventTimeLimit, calculatePoolPerformance);
log.info("Settings: sharedThreadPoolSize={}, maxEventTimeLimit={}, sharedThreadPerformanceCheck={}",
sharedThreadPoolSize, maxEventTimeLimit, sharedThreadPerformanceCheck);
}
}

View File

@ -32,7 +32,7 @@ public final class OsgiPropertyConstants {
public static final String ANTI_ENTROPY_PERIOD_MILLIS = "antiEntropyPeriod";
public static final int ANTI_ENTROPY_PERIOD_MILLIS_DEFAULT = 5000;
public static final String EC_FLOW_RULE_STORE_PERSISTENCE_ENABLED = "flowRuleStorePersistenceEnabled";
public static final String EC_FLOW_RULE_STORE_PERSISTENCE_ENABLED = "persistenceEnabled";
public static final boolean EC_FLOW_RULE_STORE_PERSISTENCE_ENABLED_DEFAULT = false;
public static final String MAX_BACKUP_COUNT = "backupCount";

View File

@ -126,13 +126,13 @@ public class OpenFlowControllerImpl implements OpenFlowController {
protected NetworkConfigRegistry netCfgService;
/** Port numbers (comma separated) used by OpenFlow protocol; default is 6633,6653. */
private String openflowPortsValue = OFPORTS_DEFAULT;
private String openflowPorts = OFPORTS_DEFAULT;
/** Number of controller worker threads. */
private int workerThreads = WORKER_THREADS_DEFAULT;
/** TLS mode for OpenFlow channel; options are: disabled [default], enabled, strict. */
private String tlsModeString;
private String tlsMode;
/** File path to key store for TLS connections. */
private String keyStore;

View File

@ -183,18 +183,18 @@ public class GeneralDeviceProvider extends AbstractProvider
/**
* Configure poll frequency for port status and statistics; default is 10 sec.
*/
private int statsPollFrequency = STATS_POLL_FREQUENCY_DEFAULT;
private int deviceStatsPollFrequency = STATS_POLL_FREQUENCY_DEFAULT;
/**
* Configure probe frequency for checking device availability; default is 10 sec.
*/
private int probeFrequency = PROBE_FREQUENCY_DEFAULT;
private int deviceProbeFrequency = PROBE_FREQUENCY_DEFAULT;
/**
* Configure timeout in seconds for device operations that are supposed to take a short time
* (e.g. checking device reachability); default is 10 seconds.
*/
private int opTimeoutShort = OP_TIMEOUT_SHORT_DEFAULT;
private int deviceOperationTimeoutShort = OP_TIMEOUT_SHORT_DEFAULT;
//FIXME to be removed when netcfg will issue device events in a bundle or
//ensures all configuration needed is present
@ -252,26 +252,26 @@ public class GeneralDeviceProvider extends AbstractProvider
}
Dictionary<?, ?> properties = context.getProperties();
final int oldStatsPollFrequency = statsPollFrequency;
statsPollFrequency = Tools.getIntegerProperty(
final int oldStatsPollFrequency = deviceStatsPollFrequency;
deviceStatsPollFrequency = Tools.getIntegerProperty(
properties, STATS_POLL_FREQUENCY, STATS_POLL_FREQUENCY_DEFAULT);
log.info("Configured. {} is configured to {} seconds",
STATS_POLL_FREQUENCY, statsPollFrequency);
final int oldProbeFrequency = probeFrequency;
probeFrequency = Tools.getIntegerProperty(
STATS_POLL_FREQUENCY, deviceStatsPollFrequency);
final int oldProbeFrequency = deviceProbeFrequency;
deviceProbeFrequency = Tools.getIntegerProperty(
properties, PROBE_FREQUENCY, PROBE_FREQUENCY_DEFAULT);
log.info("Configured. {} is configured to {} seconds",
PROBE_FREQUENCY, probeFrequency);
opTimeoutShort = Tools.getIntegerProperty(
PROBE_FREQUENCY, deviceProbeFrequency);
deviceOperationTimeoutShort = Tools.getIntegerProperty(
properties, OP_TIMEOUT_SHORT, OP_TIMEOUT_SHORT_DEFAULT);
log.info("Configured. {} is configured to {} seconds",
OP_TIMEOUT_SHORT, opTimeoutShort);
OP_TIMEOUT_SHORT, deviceOperationTimeoutShort);
if (oldStatsPollFrequency != statsPollFrequency) {
if (oldStatsPollFrequency != deviceStatsPollFrequency) {
rescheduleStatsPollingTasks();
}
if (oldProbeFrequency != probeFrequency) {
if (oldProbeFrequency != deviceProbeFrequency) {
rescheduleProbeTask(true);
}
}
@ -283,8 +283,8 @@ public class GeneralDeviceProvider extends AbstractProvider
}
probeTask = probeExecutor.scheduleAtFixedRate(
this::triggerProbeAllDevices,
deelay ? probeFrequency : 0,
probeFrequency,
deelay ? deviceProbeFrequency : 0,
deviceProbeFrequency,
TimeUnit.SECONDS);
}
}
@ -370,7 +370,7 @@ public class GeneralDeviceProvider extends AbstractProvider
}
return getFutureWithDeadline(
handshaker.isReachable(), "checking reachability",
deviceId, false, opTimeoutShort);
deviceId, false, deviceOperationTimeoutShort);
}
private boolean isConnected(DeviceId deviceId) {
@ -404,7 +404,7 @@ public class GeneralDeviceProvider extends AbstractProvider
: portAdmin.disable(portNumber);
final String descr = (enable ? "enabling" : "disabling") + " port " + portNumber;
getFutureWithDeadline(
modifyTask, descr, deviceId, null, opTimeoutShort);
modifyTask, descr, deviceId, null, deviceOperationTimeoutShort);
}
@Override
@ -475,7 +475,7 @@ public class GeneralDeviceProvider extends AbstractProvider
// Start connection via handshaker.
final Boolean connectSuccess = getFutureWithDeadline(
handshaker.connect(), "initiating connection",
deviceId, false, opTimeoutShort);
deviceId, false, deviceOperationTimeoutShort);
if (!connectSuccess) {
log.warn("Unable to connect to {}", deviceId);
}
@ -652,7 +652,7 @@ public class GeneralDeviceProvider extends AbstractProvider
handshakersWithListeners.remove(deviceId);
final boolean disconnectSuccess = getFutureWithDeadline(
handshaker.disconnect(), "performing disconnection",
deviceId, false, opTimeoutShort);
deviceId, false, deviceOperationTimeoutShort);
if (!disconnectSuccess) {
log.warn("Unable to disconnect from {}", deviceId);
}
@ -831,7 +831,7 @@ public class GeneralDeviceProvider extends AbstractProvider
? new SecureRandom().nextInt(10) : 0;
return statsExecutor.scheduleAtFixedRate(
exceptionSafe(() -> updatePortStatistics(deviceId)),
delay, statsPollFrequency, TimeUnit.SECONDS);
delay, deviceStatsPollFrequency, TimeUnit.SECONDS);
});
}

View File

@ -26,7 +26,7 @@ public final class OsgiPropertyConstants {
public static final String PROP_ENABLED = "enabled";
public static final boolean ENABLED_DEFAULT = true;
public static final String PROP_USE_BDDP = "useBDDP";
public static final String PROP_USE_BDDP = "useBddp";
public static final boolean USE_BDDP_DEFAULT = true;
public static final String PROP_PROBE_RATE = "probeRate";

View File

@ -112,7 +112,7 @@ public class NetworkConfigLinksProvider
private int probeRate = PROBE_RATE_DEFAULT;
/** Number of millis beyond which an LLDP packet will not be accepted. */
private int maxDiscoveryDelayMs = DISCOVERY_DELAY_DEFAULT;
private int maxLldpAge = DISCOVERY_DELAY_DEFAULT;
// Device link discovery helpers.
protected final Map<DeviceId, LinkDiscovery> discoverers = new ConcurrentHashMap<>();
@ -284,7 +284,7 @@ public class NetworkConfigLinksProvider
@Override
public long maxDiscoveryDelay() {
return maxDiscoveryDelayMs;
return maxLldpAge;
}
}

View File

@ -26,7 +26,7 @@ public final class OsgiPropertyConstants {
public static final String PROP_PROBE_RATE = "probeRate";
public static final int PROBE_RATE_DEFAULT = 3000;
public static final String PROP_DISCOVERY_DELAY = "maxLLDPAge";
public static final String PROP_DISCOVERY_DELAY = "maxLldpAge";
public static final int DISCOVERY_DELAY_DEFAULT = 1000;
}

View File

@ -147,7 +147,7 @@ public class CfgDefGenerator {
String comment = field.getComment();
return comment != null ? comment : NO_DESCRIPTION;
}
return null;
throw new IllegalStateException("cfgdef could not find a variable named " + name + " in " + javaClass.getName());
}
private String elaborate(AnnotationValue value) {