Package eu.mosaic_cloud.tools.exceptions.core

Examples of eu.mosaic_cloud.tools.exceptions.core.IgnoredException


        final ChannelMessage message;
        try {
          message = this.coder.decode (packet);
          Preconditions.checkNotNull (message);
        } catch (final Throwable exception) {
          throw (new IgnoredException (exception, "unexpected error encountered while decoding the inbound packet; aborting!"));
        }
        if (!Threading.offer (this.inboundMessages, message, this.pollTimeout))
          throw (new IgnoredException (new BufferOverflowException (), "queue overflow error encountered while enqueueing inbound message; aborting!"));
      }
      this.transcript.traceDebugging ("executed decoder.");
    }
View Full Code Here


        if (this.inboundActive) {
          this.transcript.traceDebugging ("dispatching received callback...");
          try {
            this.channelCallbacks.received (this.channel.controllerProxy, message);
          } catch (final Throwable exception) {
            throw (new IgnoredException (exception, "unexpected error encountered while dispatching received callback; aborting!"));
          }
        } else
          this.transcript.traceError ("discarding received callback due to closed inbound flow;");
      } else {
        if (this.inboundActive && !this.channel.input.isOpen ()) {
          this.transcript.traceDebugging ("dispatching closed inbound flow callback...");
          this.inboundActive = false;
          try {
            this.channelCallbacks.closed (this.channel.controllerProxy, ChannelFlow.Inbound);
          } catch (final Throwable exception) {
            throw (new IgnoredException (exception, "unexpected error encountered while dispatching closed inbound flow callback; aborting!"));
          }
        }
      }
      if (this.outboundActive && !this.channel.output.isOpen ()) {
        this.transcript.traceDebugging ("dispatching closed outbound flow callback...");
        this.outboundActive = false;
        try {
          this.channelCallbacks.closed (this.channel.controllerProxy, ChannelFlow.Outbound);
        } catch (final Throwable exception) {
          throw (new IgnoredException (exception, "unexpected error encountered while dispatching closed outbound flow callback; aborting!"));
        }
      }
      if (!this.outboundActive && !this.inboundActive)
        this.triggerShutdown ();
      this.transcript.traceDebugging ("executed dispatcher.");
View Full Code Here

      this.transcript.traceDebugging ("destroying dispatcher...");
      this.transcript.traceDebugging ("dispatching terminated callback...");
      try {
        this.channelCallbacks.terminated (this.channel.controllerProxy);
      } catch (final Throwable exception) {
        throw (new IgnoredException (exception, "unexpected error encountered while dispatching terminated callback; aborting!"));
      }
      this.transcript.traceDebugging ("destroyed dispatcher.");
    }
View Full Code Here

      this.transcript.traceDebugging ("initializing dispatcher...");
      this.transcript.traceDebugging ("dispatching initialized callback...");
      try {
        this.channelCallbacks.initialized (this.channel.controllerProxy);
      } catch (final Throwable exception) {
        throw (new IgnoredException (exception, "unexpected error encountered while dispatching initialized callback; aborting!"));
      }
      this.transcript.traceDebugging ("initialized dispatcher.");
    }
View Full Code Here

        final ByteBuffer packet;
        try {
          packet = this.coder.encode (message);
          Preconditions.checkNotNull (packet);
        } catch (final Throwable exception) {
          throw (new IgnoredException (exception, "unexpected error encountered while encoding the outbound message; aborting!"));
        }
        if (!Threading.offer (this.outboundPackets, packet, this.pollTimeout))
          throw (new IgnoredException (new BufferOverflowException (), "unexpected queue overflow error encountered while enqueueing outbound packet; aborting!"));
        this.channel.selector.wakeup ();
      }
      this.transcript.traceDebugging ("executed encoder.");
    }
View Full Code Here

              packet.mark ();
              final int packetSize = packet.getInt ();
              Preconditions.checkArgument (packetSize == packet.remaining (), "invalid outbound packet encoding");
              packet.reset ();
            } catch (final IllegalArgumentException exception) {
              throw (new IgnoredException (exception, "unexpected validation error encountered while polling outbound packet; aborting!"));
            }
            this.outputPending = packet;
          }
        }
      } else {
        if (this.outputPending != null) {
          this.transcript.traceError ("discarding outbound packet due to closed outbound flow;");
          this.outputPending = null;
        }
      }
      try {
        if ((this.inputPending != null) && (this.inputKey == null))
          this.inputKey = ((SelectableChannel) this.input).register (this.selector, SelectionKey.OP_READ);
        else if ((this.inputKey != null) && (this.inputPending == null)) {
          this.inputKey.cancel ();
          this.inputKey = null;
        }
        if ((this.outputPending != null) && (this.outputKey == null) && this.output.isOpen ())
          this.outputKey = ((SelectableChannel) this.output).register (this.selector, SelectionKey.OP_WRITE);
        else if ((this.outputKey != null) && (this.outputPending == null)) {
          this.outputKey.cancel ();
          this.outputKey = null;
        }
      } catch (final IOException exception) {
        throw (new IgnoredException (exception, "i/o error encountered while polling flows; aborting!"));
      }
      try {
        this.selector.select (this.pollTimeout);
      } catch (final IOException exception) {
        throw (new IgnoredException (exception, "i/o error encountered while polling flows; aborting!"));
      }
      final boolean inputValid;
      final boolean outputValid;
      if (this.inputKey != null) {
        inputValid = this.inputKey.isValid () && this.input.isOpen ();
        if (inputValid && this.inputKey.isReadable ()) {
          this.transcript.traceDebugging ("accessing input flow...");
          try {
            try {
              final int outcome = this.input.read (this.inputPending);
              if (outcome == -1)
                this.input.close ();
            } catch (final ClosedChannelException exception) {
              this.exceptions.traceIgnoredException (exception);
            }
          } catch (final IOException exception) {
            throw (new IgnoredException (exception, "i/o error encountered while accessing input flow; aborting!"));
          }
        }
      } else
        inputValid = true;
      if (this.outputKey != null) {
        outputValid = this.outputKey.isValid () && this.output.isOpen ();
        if (outputValid && this.outputKey.isWritable ()) {
          this.transcript.traceDebugging ("accessing output flow...");
          try {
            try {
              this.output.write (this.outputPending);
            } catch (final ClosedChannelException exception) {
              this.exceptions.traceIgnoredException (exception);
            }
          } catch (final IOException exception) {
            throw (new IgnoredException (exception, "i/o error encountered while accessing output flow; aborting!"));
          }
        }
      } else
        outputValid = true;
      if (this.inputPending != null) {
        while (true) {
          if (this.inputPendingSize == -1) {
            if (this.inputPending.position () >= 4) {
              this.inputPendingSize = this.inputPending.getInt (0) + 4;
              if (this.inputPending.capacity () < this.inputPendingSize) {
                if (this.inputPendingSize > this.maximumPacketSize)
                  throw (new IgnoredException (new BufferOverflowException (), "unexpected inbound packet size; aborting!"));
                final ByteBuffer buffer = ByteBuffer.allocate (this.inputPendingSize);
                this.inputPending.compact ();
                buffer.put (this.inputPending);
                this.inputPending = buffer;
              }
            }
          }
          if (this.inputPendingSize != -1) {
            final ByteBuffer packet;
            if (this.inputPending.position () == this.inputPendingSize) {
              packet = this.inputPending;
              this.inputPending = null;
              this.inputPendingSize = -1;
            } else if (this.inputPending.position () > this.inputPendingSize) {
              this.inputPending.flip ();
              packet = ByteBuffer.allocate (this.inputPendingSize);
              final ByteBuffer inputPendingSlice = this.inputPending.asReadOnlyBuffer ();
              inputPendingSlice.limit (this.inputPendingSize);
              packet.put (inputPendingSlice);
              this.inputPending.position (this.inputPendingSize);
              this.inputPending.compact ();
              this.inputPendingSize = -1;
            } else
              packet = null;
            if (packet != null) {
              packet.flip ();
              if (!Threading.offer (this.inboundPackets, packet.asReadOnlyBuffer (), this.pollTimeout))
                throw (new IgnoredException (new BufferOverflowException (), "unexpected queue overflow error encountered while enqueueing inbound packet; aborting!"));
            }
          }
          if ((this.inputPending == null) || (this.inputPending.position () < 4) || ((this.inputPendingSize != -1) && (this.inputPendingSize > this.inputPending.position ())))
            break;
        }
View Full Code Here

      this.transcript.traceDebugging ("initializing flows...");
      try {
        ((SelectableChannel) this.input).configureBlocking (false);
        ((SelectableChannel) this.output).configureBlocking (false);
      } catch (final IOException exception) {
        throw (new IgnoredException (exception, "i/o error encountered while configuring flows; aborting!"));
      }
      this.transcript.traceDebugging ("initialized flows.");
    }
View Full Code Here

TOP

Related Classes of eu.mosaic_cloud.tools.exceptions.core.IgnoredException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.