Uploaded image for project: 'JBoss Remoting (3+)'
  1. JBoss Remoting (3+)
  2. REM3-419

IntIndexHashMap tuning

XMLWordPrintable

    • Icon: Issue Issue
    • Resolution: Done
    • Icon: Major Major
    • 5.0.30.Final
    • 5.0.29.Final
    • None

      The Remoting class IntIndexHashMap is used in RemoteConnectionChannel to store the outbound messages leaving the channel endpoint and the inbound messages arriving at the channel endpoint.

          private final IntIndexMap<OutboundMessage> outboundMessages = new IntIndexHashMap<OutboundMessage>(OutboundMessage.INDEXER, Equaller.IDENTITY, 512, 0.5f);
          private final IntIndexMap<InboundMessage> inboundMessages = new IntIndexHashMap<InboundMessage>(InboundMessage.INDEXER, Equaller.IDENTITY, 512, 0.5f);
      

      For example, when an EJBClientChannel instance wants to send an invocation to an EJBServerChannel instance, it will call RemoteConnectionChannel.writeMessage() to create an OutboundMessage instance and write that instance into the outboundMessages map:

          public MessageOutputStream writeMessage() throws IOException {
              int tries = 50;
              IntIndexMap<OutboundMessage> outboundMessages = this.outboundMessages;
              openOutboundMessage();
              boolean ok = false;
              try {
                  final Random random = ThreadLocalRandom.current();
                  while (tries > 0) {
                      final int id = random.nextInt() & 0xfffe;
                      if (! outboundMessages.containsKey(id)) {
                          OutboundMessage message = new OutboundMessage((short) id, this, outboundWindow, maxOutboundMessageSize, messageAckTimeout);
                          OutboundMessage existing = outboundMessages.putIfAbsent(message);
                          if (existing == null) {
                              ok = true;
                              return message;
                          }
                      }
                      tries --;
                  }
                  throw log.channelBusy();
              } finally {
                  if (! ok) {
                      closeOutboundMessage();
                  }
              }
          }
      

      We are finding that, under certain circumstances, the limit of 50 on the attempts to write a OutboundMessage into the map are failing, resulting a ChannelBusyException, and so failed invocations of the EJB client.

      So the question arises: when using an IntIndexHashMap, how can it be tuned to avoid such errors?

            flaviarnn Flavia Rainone
            rachmato@redhat.com Richard Achmatowicz
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: