private Map<String, GroupID> readGroupnameIDMapFromL2(PwProvider pwProvider) { Map<String, GroupID> map; try { map = new ConfigInfoFromL2Impl(this.config, pwProvider).getGroupNameIDMapFromL2(); } catch (ConfigurationSetupException e) { throw new TCRuntimeException(e); } return map; }
@Override public L1ReconnectPropertiesDocument getL1ReconnectPropertiesFromL2() throws ConfigurationSetupException { return getAndParseDocumentFromL2("L1 Reconnect Properties", L1_RECONNECT_PROPERTIES_FROML2_SERVELET_PATH, new FactoryParser<L1ReconnectPropertiesDocument>() { @Override public L1ReconnectPropertiesDocument parse(InputStream in2) throws Exception { return L1ReconnectPropertiesDocument.Factory.parse(in2); } }); }
public ConfigInfoFromL2Impl(final L1ConfigurationSetupManager configSetupManager, PwProvider pwProvider) { this(getConnectionsFromL1Config(configSetupManager), pwProvider); }
private void setupL1ReconnectProperties(PwProvider pwProvider) throws ConfigurationSetupException { L1ReconnectPropertiesDocument l1ReconnectPropFromL2 = new ConfigInfoFromL2Impl(configSetupManager, pwProvider) .getL1ReconnectPropertiesFromL2(); boolean l1ReconnectEnabled = l1ReconnectPropFromL2.getL1ReconnectProperties().getL1ReconnectEnabled(); int l1ReconnectTimeout = l1ReconnectPropFromL2.getL1ReconnectProperties().getL1ReconnectTimeout().intValue(); int l1ReconnectSendqueuecap = l1ReconnectPropFromL2.getL1ReconnectProperties().getL1ReconnectSendqueuecap() .intValue(); int l1ReconnectMaxdelayedacks = l1ReconnectPropFromL2.getL1ReconnectProperties().getL1ReconnectMaxDelayedAcks() .intValue(); int l1ReconnectSendwindow = l1ReconnectPropFromL2.getL1ReconnectProperties().getL1ReconnectSendwindow().intValue(); this.l1ReconnectConfig = new L1ReconnectConfigImpl(l1ReconnectEnabled, l1ReconnectTimeout, l1ReconnectSendqueuecap, l1ReconnectMaxdelayedacks, l1ReconnectSendwindow); }
@Override public Map<String, GroupID> getGroupNameIDMapFromL2() throws ConfigurationSetupException { Map<String, GroupID> map = new HashMap<String, GroupID>(); GroupnameIdMapDocument groupnameIdMapDocument = getAndParseDocumentFromL2("Groupname ID Map", GROUPID_MAP_SERVLET_PATH, new FactoryParser<GroupnameIdMapDocument>() { @Override public GroupnameIdMapDocument parse(InputStream in2) throws Exception { return GroupnameIdMapDocument.Factory .parse(in2); } }); for (GroupnameId gid : groupnameIdMapDocument.getGroupnameIdMap().getGroupnameIdArray()) { int groupID = gid.getGid().intValue(); if (groupID <= -1) { throw new ConfigurationSetupException("Wrong group ID " + groupID + " of " + gid.getName()); } map.put(gid.getName(), new GroupID(groupID)); } // a little bit verification int groupCount = getGroupCount(); if (map.size() != groupCount) { throw new ConfigurationSetupException("Expect group count " + groupCount + " but see mapping " + map.size()); } return map; }
configSetupManager, pwProvider); ServerGroups serverGroupsFromL2 = new ConfigInfoFromL2Impl(configSetupManager, pwProvider).getServerGroupsFromL2() .getServerGroups();
private int getGroupCount() throws ConfigurationSetupException { return getServerGroupsFromL2().getServerGroups().getServerGroupArray().length; }
private InputStream getPropertiesFromServerViaHttp(final String message, final String httpPathExtension) throws ConfigurationSetupException { StringBuilder text = new StringBuilder("Can't connect to "); if (connections.length > 1) text.append("any of the servers ["); else text.append("server ["); for (int i = 0; i < connections.length; i++) { if (i > 0) text.append(", "); text.append(connections[i]); } text.append("]."); boolean loggedInConsole = false; int count = 0; while (true) { count++; InputStream in = getPropertiesFromL2Stream(message, httpPathExtension); if (in != null) { return in; } if (loggedInConsole == false) { consoleLogger.warn(text + "Retrying... \n"); loggedInConsole = true; } if (connections.length > 1) { logger.warn(text + "Retrying... \n"); } if (MAX_CONNECT_TRIES > 0 && count >= MAX_CONNECT_TRIES) { throw new ConfigurationSetupException(text.toString()); } ThreadUtil.reallySleep(connectRetryInterval); } }
private <T extends XmlObject> T getAndParseDocumentFromL2(String message, String httpPath, FactoryParser<T> factoryParser) throws ConfigurationSetupException { int tries = 0; while (true) { InputStream in = getPropertiesFromServerViaHttp(message, httpPath); try { try { return new ParseXmlObjectStream<T>().parse(message, in, factoryParser); } catch (SAXParseException e) { if (tries++ < 10) { logger.warn("Got an XML parse exception retrieving L1 reconnect properties. Retrying..."); continue; } else { throw e; } } } catch (Exception e) { consoleLogger.error(e.getMessage()); logger.error(e); throw new AssertionError(e); } } }
private void setupL1ReconnectProperties(PwProvider pwProvider) throws ConfigurationSetupException { L1ReconnectPropertiesDocument l1ReconnectPropFromL2 = new ConfigInfoFromL2Impl(configSetupManager, pwProvider) .getL1ReconnectPropertiesFromL2(); boolean l1ReconnectEnabled = l1ReconnectPropFromL2.getL1ReconnectProperties().getL1ReconnectEnabled(); int l1ReconnectTimeout = l1ReconnectPropFromL2.getL1ReconnectProperties().getL1ReconnectTimeout().intValue(); int l1ReconnectSendqueuecap = l1ReconnectPropFromL2.getL1ReconnectProperties().getL1ReconnectSendqueuecap() .intValue(); int l1ReconnectMaxdelayedacks = l1ReconnectPropFromL2.getL1ReconnectProperties().getL1ReconnectMaxDelayedAcks() .intValue(); int l1ReconnectSendwindow = l1ReconnectPropFromL2.getL1ReconnectProperties().getL1ReconnectSendwindow().intValue(); this.l1ReconnectConfig = new L1ReconnectConfigImpl(l1ReconnectEnabled, l1ReconnectTimeout, l1ReconnectSendqueuecap, l1ReconnectMaxdelayedacks, l1ReconnectSendwindow); }
@Override public Map<String, GroupID> getGroupNameIDMapFromL2() throws ConfigurationSetupException { Map<String, GroupID> map = new HashMap<String, GroupID>(); GroupnameIdMapDocument groupnameIdMapDocument = getAndParseDocumentFromL2("Groupname ID Map", GROUPID_MAP_SERVLET_PATH, new FactoryParser<GroupnameIdMapDocument>() { @Override public GroupnameIdMapDocument parse(InputStream in2) throws Exception { return GroupnameIdMapDocument.Factory .parse(in2); } }); for (GroupnameId gid : groupnameIdMapDocument.getGroupnameIdMap().getGroupnameIdArray()) { int groupID = gid.getGid().intValue(); if (groupID <= -1) { throw new ConfigurationSetupException("Wrong group ID " + groupID + " of " + gid.getName()); } map.put(gid.getName(), new GroupID(groupID)); } // a little bit verification int groupCount = getGroupCount(); if (map.size() != groupCount) { throw new ConfigurationSetupException("Expect group count " + groupCount + " but see mapping " + map.size()); } return map; }
configSetupManager, pwProvider); ServerGroups serverGroupsFromL2 = new ConfigInfoFromL2Impl(configSetupManager, pwProvider).getServerGroupsFromL2() .getServerGroups();
private int getGroupCount() throws ConfigurationSetupException { return getServerGroupsFromL2().getServerGroups().getServerGroupArray().length; }
private InputStream getPropertiesFromServerViaHttp(final String message, final String httpPathExtension) throws ConfigurationSetupException { StringBuilder text = new StringBuilder("Can't connect to "); if (connections.length > 1) text.append("any of the servers ["); else text.append("server ["); for (int i = 0; i < connections.length; i++) { if (i > 0) text.append(", "); text.append(connections[i]); } text.append("]."); boolean loggedInConsole = false; int count = 0; while (true) { count++; InputStream in = getPropertiesFromL2Stream(message, httpPathExtension); if (in != null) { return in; } if (loggedInConsole == false) { consoleLogger.warn(text + "Retrying... \n"); loggedInConsole = true; } if (connections.length > 1) { logger.warn(text + "Retrying... \n"); } if (MAX_CONNECT_TRIES > 0 && count >= MAX_CONNECT_TRIES) { throw new ConfigurationSetupException(text.toString()); } ThreadUtil.reallySleep(connectRetryInterval); } }
private <T extends XmlObject> T getAndParseDocumentFromL2(String message, String httpPath, FactoryParser<T> factoryParser) throws ConfigurationSetupException { int tries = 0; while (true) { InputStream in = getPropertiesFromServerViaHttp(message, httpPath); try { try { return new ParseXmlObjectStream<T>().parse(message, in, factoryParser); } catch (SAXParseException e) { if (tries++ < 10) { logger.warn("Got an XML parse exception retrieving L1 reconnect properties. Retrying..."); continue; } else { throw e; } } } catch (Exception e) { consoleLogger.error(e.getMessage()); logger.error(e); throw new AssertionError(e); } } }
private void setupL1ReconnectProperties(PwProvider pwProvider) throws ConfigurationSetupException { L1ReconnectPropertiesDocument l1ReconnectPropFromL2 = new ConfigInfoFromL2Impl(configSetupManager, pwProvider) .getL1ReconnectPropertiesFromL2(); boolean l1ReconnectEnabled = l1ReconnectPropFromL2.getL1ReconnectProperties().getL1ReconnectEnabled(); int l1ReconnectTimeout = l1ReconnectPropFromL2.getL1ReconnectProperties().getL1ReconnectTimeout().intValue(); int l1ReconnectSendqueuecap = l1ReconnectPropFromL2.getL1ReconnectProperties().getL1ReconnectSendqueuecap() .intValue(); int l1ReconnectMaxdelayedacks = l1ReconnectPropFromL2.getL1ReconnectProperties().getL1ReconnectMaxDelayedAcks() .intValue(); int l1ReconnectSendwindow = l1ReconnectPropFromL2.getL1ReconnectProperties().getL1ReconnectSendwindow().intValue(); this.l1ReconnectConfig = new L1ReconnectConfigImpl(l1ReconnectEnabled, l1ReconnectTimeout, l1ReconnectSendqueuecap, l1ReconnectMaxdelayedacks, l1ReconnectSendwindow); }
private Map<String, GroupID> readGroupnameIDMapFromL2(PwProvider pwProvider) { Map<String, GroupID> map; try { map = new ConfigInfoFromL2Impl(this.config, pwProvider).getGroupNameIDMapFromL2(); } catch (ConfigurationSetupException e) { throw new TCRuntimeException(e); } return map; }
@Override public Map<String, GroupID> getGroupNameIDMapFromL2() throws ConfigurationSetupException { Map<String, GroupID> map = new HashMap<String, GroupID>(); GroupnameIdMapDocument groupnameIdMapDocument = getAndParseDocumentFromL2("Groupname ID Map", GROUPID_MAP_SERVLET_PATH, new FactoryParser<GroupnameIdMapDocument>() { @Override public GroupnameIdMapDocument parse(InputStream in2) throws Exception { return GroupnameIdMapDocument.Factory .parse(in2); } }); for (GroupnameId gid : groupnameIdMapDocument.getGroupnameIdMap().getGroupnameIdArray()) { int groupID = gid.getGid().intValue(); if (groupID <= -1) { throw new ConfigurationSetupException("Wrong group ID " + groupID + " of " + gid.getName()); } map.put(gid.getName(), new GroupID(groupID)); } // a little bit verification int groupCount = getGroupCount(); if (map.size() != groupCount) { throw new ConfigurationSetupException("Expect group count " + groupCount + " but see mapping " + map.size()); } return map; }
@Override public void validateGroupInfo(final PwProvider pwProvider) throws ConfigurationSetupException { PreparedComponentsFromL2Connection connectionComponents = new PreparedComponentsFromL2Connection(configSetupManager, pwProvider); ServerGroups serverGroupsFromL2 = new ConfigInfoFromL2Impl(configSetupManager, pwProvider).getServerGroupsFromL2() .getServerGroups();
@Override public L1ReconnectPropertiesDocument getL1ReconnectPropertiesFromL2() throws ConfigurationSetupException { return getAndParseDocumentFromL2("L1 Reconnect Properties", L1_RECONNECT_PROPERTIES_FROML2_SERVELET_PATH, new FactoryParser<L1ReconnectPropertiesDocument>() { @Override public L1ReconnectPropertiesDocument parse(InputStream in2) throws Exception { return L1ReconnectPropertiesDocument.Factory.parse(in2); } }); }