Performance testing has identified contention on getInstance() methods.
It turns out that we can pre-create the instance and then get it in a
lock-free manner.
Change-Id: I49c219d5954fa792218040a0ae66bf344992413a
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
/**
- *
+ *
*/
public class ActionSetNwDstReactor extends ConvertReactor<SetNwDstActionCase> {
-
- private static ActionSetNwDstReactor instance;
-
+
+ private static ActionSetNwDstReactor INSTANCE = new ActionSetNwDstReactor();
+
private ActionSetNwDstReactor() {
//NOOP
}
-
+
/**
* @return singleton
*/
- public static synchronized ActionSetNwDstReactor getInstance() {
- if (instance == null) {
- instance = new ActionSetNwDstReactor();
- }
- return instance;
+ public static ActionSetNwDstReactor getInstance() {
+ return INSTANCE;
}
-
+
@Override
- protected void initMappings(Map<Short, Convertor<SetNwDstActionCase,?>> conversions,
- Map<InjectionKey, ResultInjector<?,?>> injections) {
+ protected void initMappings(final Map<Short, Convertor<SetNwDstActionCase,?>> conversions,
+ final Map<InjectionKey, ResultInjector<?,?>> injections) {
ActionSetNwDstReactorMappingFactory.addSetNwDstConvertors(conversions);
ActionSetNwDstReactorMappingFactory.addSetNwDstInjectors(injections);
}
-
+
@Override
- protected InjectionKey buildInjectionKey(short version,
- Object convertedItem, Object target) {
+ protected InjectionKey buildInjectionKey(final short version,
+ final Object convertedItem, final Object target) {
InjectionResultTargetKey key = null;
if (convertedItem != null) {
key = new InjectionResultTargetKey(version, target.getClass().getName(), convertedItem.getClass().getName());
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
/**
- *
+ *
*/
public class ActionSetNwSrcReactor extends ConvertReactor<SetNwSrcActionCase> {
-
- private static ActionSetNwSrcReactor instance;
-
+
+ private static ActionSetNwSrcReactor INSTANCE = new ActionSetNwSrcReactor();
+
private ActionSetNwSrcReactor() {
//NOOP
}
-
+
/**
* @return singleton
*/
- public static synchronized ActionSetNwSrcReactor getInstance() {
- if (instance == null) {
- instance = new ActionSetNwSrcReactor();
- }
- return instance;
+ public static ActionSetNwSrcReactor getInstance() {
+ return INSTANCE;
}
-
+
@Override
- protected void initMappings(Map<Short, Convertor<SetNwSrcActionCase,?>> conversions,
- Map<InjectionKey, ResultInjector<?,?>> injections) {
+ protected void initMappings(final Map<Short, Convertor<SetNwSrcActionCase,?>> conversions,
+ final Map<InjectionKey, ResultInjector<?,?>> injections) {
ActionSetNwSrcReactorMappingFactory.addSetNwSrcConvertors(conversions);
ActionSetNwSrcReactorMappingFactory.addSetNwSrcInjectors(injections);
}
-
+
@Override
- protected InjectionKey buildInjectionKey(short version,
- Object convertedItem, Object target) {
+ protected InjectionKey buildInjectionKey(final short version,
+ final Object convertedItem, final Object target) {
InjectionResultTargetKey key = null;
if (convertedItem != null) {
key = new InjectionResultTargetKey(version, target.getClass().getName(), convertedItem.getClass().getName());
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
/**
- *
+ *
*/
public class FlowFlagReactor extends ConvertReactor<FlowModFlags> {
-
- private static FlowFlagReactor instance;
-
+
+ private static FlowFlagReactor INSTANCE = new FlowFlagReactor();
+
private FlowFlagReactor() {
//NOOP
}
-
+
/**
* @return singleton
*/
- public static synchronized FlowFlagReactor getInstance() {
- if (instance == null) {
- instance = new FlowFlagReactor();
- }
- return instance;
+ public static FlowFlagReactor getInstance() {
+ return INSTANCE;
}
-
+
@Override
- protected void initMappings(Map<Short, Convertor<FlowModFlags, ?>> conversions,
- Map<InjectionKey, ResultInjector<?,?>> injections) {
+ protected void initMappings(final Map<Short, Convertor<FlowModFlags, ?>> conversions,
+ final Map<InjectionKey, ResultInjector<?,?>> injections) {
FlowFlagReactorMappingFactory.addFlowFlagsConvertors(conversions);
FlowFlagReactorMappingFactory.addFlowFlagsIjectors(injections);
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
/**
- *
+ *
*/
public class MatchReactor extends ConvertReactor<Match> {
-
- private static MatchReactor instance;
-
+
+ private static MatchReactor INSTANCE = new MatchReactor();
+
private MatchReactor() {
//NOOP
}
-
+
/**
* @return singleton
*/
- public static synchronized MatchReactor getInstance() {
- if (instance == null) {
- instance = new MatchReactor();
- }
- return instance;
+ public static MatchReactor getInstance() {
+ return INSTANCE;
}
-
+
@Override
- protected void initMappings(Map<Short, Convertor<Match,?>> conversions,
- Map<InjectionKey, ResultInjector<?,?>> injections) {
+ protected void initMappings(final Map<Short, Convertor<Match,?>> conversions,
+ final Map<InjectionKey, ResultInjector<?,?>> injections) {
MatchReactorMappingFactory.addMatchConvertors(conversions);
MatchReactorMappingFactory.addMatchIjectors(injections);
}
-
}