I am setting up fallback logic for a DACS Open API system using a comma separated list for the "dacs.daemon" AuthorizationSystem property.
When there is no network connection to the first item in the list, this works as expected and makes a connection to the second item. However when the first item in the list returns a connection down, as we have hit the 8 connection limit on that server it does not fall back to the second item.
My code:
public DACSClient(String daemonHostRed, String daemonHostBlue)
{
this.daemonHost = daemonHostRed + "," + daemonHostBlue;
try
{
openDACSConnection();
getDACSAgent();
}
catch (AuthorizationException e)
{
LOGGER.error("Unable to acquire DACS Authorization system", e);
//Without the DACS we can do nothing.
onAuthorizationSystemNotAvailableEvent();
}
}
private void openDACSConnection() throws AuthorizationException
{
if (dacsEventQueue == null)
{
dacsEventQueue = EventQueue.create("dacsEventQueue");
executorService = Executors.newSingleThreadScheduledExecutor(dacsFactory);
executorService.scheduleAtFixedRate(this::dispatchEventQueue, 0, 100, TimeUnit.MICROSECONDS);
}
if (dacsSystem != null)
{
//If the system is already up do nothing
return;
}
AuthorizationSystem.setProperty("dacs.daemon", daemonHost);
dacsSystem = AuthorizationSystem.acquire();
}
private void getDACSAgent() throws AuthorizationException
{
dacsAgent = dacsSystem.createAuthorizationAgent("DACS Entitlements Service", true);
try
{
while (dacsAgent.daemonConnectionState() == AuthorizationConnection.CONNECTION_PENDING)
{
//noinspection BusyWait
Thread.sleep(500);
}
if (dacsAgent.daemonConnectionState() == AuthorizationConnection.CONNECTION_UP)
{
//No way exposed in the dacs openapi to get which of the red/blue we are actually connected to.
LOGGER.info("DACS Connection UP");
getDACSService();
return;
}
}
catch (InterruptedException e)
{
LOGGER.error(e.getMessage(), e);
throw new AuthorizationException(e.getMessage());
}
LOGGER.error("DACS Connection DOWN");
closeConnection(true);
throw new AuthorizationException("DACS Connection DOWN");
}
We are NOT using the AuthorizationMCSystem, where I would expect to drop the CONNECTION_DOWN item from the list of available connections, and I do not want to make multiple connections.
What am I missing here?