void initializeCommands() { // The commands are cached here, but are just referencing the ones // stored in the CommandInitializer this.commands = CommandInitializer.getCommands(this); }
@Override public void initialize() { Map<Version, Command> versions = new HashMap<>(); versions.put(Version.GFE_57, ExecuteCQ.getCommand()); versions.put(Version.GFE_61, ExecuteCQ61.getCommand()); CommandInitializer.registerCommand(MessageType.EXECUTECQ_MSG_TYPE, versions); CommandInitializer.registerCommand(MessageType.EXECUTECQ_WITH_IR_MSG_TYPE, versions); CommandInitializer.registerCommand(MessageType.GETCQSTATS_MSG_TYPE, Collections.singletonMap(Version.GFE_57, GetCQStats.getCommand())); CommandInitializer.registerCommand(MessageType.MONITORCQ_MSG_TYPE, Collections.singletonMap(Version.GFE_57, MonitorCQ.getCommand())); CommandInitializer.registerCommand(MessageType.STOPCQ_MSG_TYPE, Collections.singletonMap(Version.GFE_57, StopCQ.getCommand())); CommandInitializer.registerCommand(MessageType.CLOSECQ_MSG_TYPE, Collections.singletonMap(Version.GFE_57, CloseCQ.getCommand())); CommandInitializer.registerCommand(MessageType.GETDURABLECQS_MSG_TYPE, Collections.singletonMap(Version.GFE_70, GetDurableCQs.getCommand())); }
public static Map<Integer, Command> getCommands(ServerConnection connection) { return getCommands(connection.getClientVersion()); } }
/** Return the <code>Version</code> represented by specified ordinal */ public static Version fromOrdinal(short ordinal, boolean forGFEClients) throws UnsupportedVersionException { if (ordinal == TOKEN_ORDINAL) { return TOKEN; } // for clients also check that there must be a commands object mapping // for processing if ((VALUES.length < ordinal + 1) || VALUES[ordinal] == null || (forGFEClients && CommandInitializer.getCommands(VALUES[ordinal]) == null)) { throw new UnsupportedVersionException(String.format( "Peer or client version with ordinal %s not supported. Highest known version is %s", ordinal, CURRENT.name)); } return VALUES[ordinal]; }
@Test public void testCommandMapContainsAllVersions() { for (Version version : Version.getAllVersions()) { org.junit.Assert.assertNotNull( "Please add a commnd set for " + version + " of Geode to CommandInitializer", CommandInitializer.getCommands(version)); } }