Method to wait until the delivery stream becomes active.

@param deliveryStreamName the delivery stream
@throws Exception
193167
protected static void waitForDeliveryStreamToBecomeAvailable(String deliveryStreamName) throws Exception {

        LOG.info("Waiting for " + deliveryStreamName + " to become ACTIVE...");

        long startTime = System.currentTimeMillis();
        long endTime = startTime + (10 * 60 * 1000);
        while (System.currentTimeMillis() < endTime) {
            try {
                Thread.sleep(1000 * 20);
            } catch (InterruptedException e) {
                // Ignore interruption (doesn't impact deliveryStream creation)
            }

            DeliveryStreamDescription deliveryStreamDescription = describeDeliveryStream(deliveryStreamName);
            String deliveryStreamStatus = deliveryStreamDescription.getDeliveryStreamStatus();
            LOG.info("  - current state: " + deliveryStreamStatus);
            if (deliveryStreamStatus.equals("ACTIVE")) {
                return;
            }
        }

        throw new AmazonServiceException("DeliveryStream " + deliveryStreamName + " never went active");
    }
106294
private static void updateDeliveryStream() throws Exception {
        DeliveryStreamDescription deliveryStreamDescription = describeDeliveryStream(deliveryStreamName);
        
        LOG.info("Updating DeliveryStream Destination: " + deliveryStreamName + " with new configuration options");
        // get(0) -> DeliveryStream currently supports only one destination per DeliveryStream
        UpdateDestinationRequest updateDestinationRequest = 
                new UpdateDestinationRequest()
                    .withDeliveryStreamName(deliveryStreamName)
                    .withCurrentDeliveryStreamVersionId(deliveryStreamDescription.getVersionId())
                    .withDestinationId(deliveryStreamDescription.getDestinations().get(0).getDestinationId());
        
        S3DestinationUpdate s3DestinationUpdate = new S3DestinationUpdate();
        s3DestinationUpdate.withPrefix(updateS3ObjectPrefix);

        BufferingHints bufferingHints = null;
        if (updateSizeInMBs != null || updateIntervalInSeconds != null) {
            bufferingHints = new BufferingHints();
            bufferingHints.setSizeInMBs(updateSizeInMBs);
            bufferingHints.setIntervalInSeconds(updateIntervalInSeconds);
        }
        s3DestinationUpdate.setBufferingHints(bufferingHints);

        // Update the role policy with new s3Prefix configuration
        putRolePolicy(updateS3ObjectPrefix);

        updateDestinationRequest.setS3DestinationUpdate(s3DestinationUpdate);

        // Update deliveryStream destination with new configuration options such as s3Prefix and Buffering Hints.
        // Can also update Compression format, KMS key values and IAM Role.
        firehoseClient.updateDestination(updateDestinationRequest);
    }
663956
public void execute() throws ActivityException {
        EventWaitInstance received = registerWaitEvents(false, true);
        if (received!=null) {
            setReturnCodeAndExitStatus(received.getCompletionCode());
            processMessage(getExternalEventInstanceDetails(received.getMessageDocumentId()));
            boolean toFinish = handleCompletionCode();
            if (toFinish && exitStatus==null)
                exitStatus = WorkStatus.STATUS_COMPLETED;
        }
        else {
            try {
                // set timeouts
                int timeout = getTimeoutSeconds();
                if (timeout > 0) {
                    loginfo("set activity timeout as " + timeout + " seconds");
                    InternalEvent delayMsg = InternalEvent.createActivityDelayMessage(getActivityInstance(), getMasterRequestId());
                    getEngine().sendDelayedInternalEvent(delayMsg, timeout,
                            ScheduledEvent.INTERNAL_EVENT_PREFIX+getActivityInstanceId()+"timeout", false);
                }
            }
            catch (MdwException e) {
                throw new ActivityException(0, "Failed to set timeout", e);
            }
        }
    }
986203
@Override
	public final void stop() throws JMSException
    {
    	externalAccessLock.readLock().lock();
    	try
		{
	        checkNotClosed();
	        if (!started)
	            return;
	        started = false;
	        
	        // Wait for running deliveries to complete ...
	        waitForDeliverySync();
		}
    	finally
    	{
    		externalAccessLock.readLock().unlock();
    	}
    }
380946
public void start() throws Exception
    {
        Preconditions.checkState(state.compareAndSet(State.LATENT, State.STARTED), "Cannot be started more than once");

        client.createContainers(queuePath);

        getInitialQueues();
        leaderLatch.start();

        service.submit
        (
            new Callable<Void>()
            {
                @Override
                public Void call() throws Exception
                {
                    while ( state.get() == State.STARTED )
                    {
                        try
                        {
                            Thread.sleep(policies.getThresholdCheckMs());
                            checkThreshold();
                        }
                        catch ( InterruptedException e )
                        {
                            // swallow the interrupt as it's only possible from either a background
                            // operation and, thus, doesn't apply to this loop or the instance
                            // is being closed in which case the while test will get it
                        }
                    }
                    return null;
                }
            }
        );
    }
872403
public final void waitForPort(final String portName) {
        final Binding binding = getPortBinding(portName);
        waitForPort(binding.getHost(), binding.getPort());
    }
793435
public void waitForHintText(String hintText, int timeout) throws Exception
    {
        int RETRY_PERIOD = 250;
        int retryNum = timeout / RETRY_PERIOD;
        for(int i=0; i < retryNum; i++)
        {
            ArrayList<View> imageViews = getCustomViews("EditText");
            for(View v: imageViews)
            {
                if(((EditText)v).getHint() == null)
                    continue;
                if(((EditText)v).getHint().equals(hintText) &&
                        v.getVisibility() == View.VISIBLE)
                    return;
            }

            this.sleep(RETRY_PERIOD);
        }
        throw new Exception(String.format("Splash screen didn't disappear after %d ms", timeout));
    }
273391
public void launch() throws Exception {
        if (init.get())
            return;
        // Register a SIGINT handler for graceful shutdown.
        if (!init.get())
            init();

        log.info("Subscribing to " + channel + " on stream Id " + streamId);
        log.info("Using aeron directory " + ctx.aeronDirectoryName());

        // Register a SIGINT handler for graceful shutdown.
        SigInt.register(() -> running.set(false));

        // Create an Aeron instance with client-provided context configuration, connect to the
        // media driver, and add a subscription for the given channel and stream using the supplied
        // dataHandler method, which will be called with new messages as they are received.
        // The Aeron and Subscription classes implement AutoCloseable, and will automatically
        // clean up resources when this try block is finished.
        //Note here that we are either creating 1 or 2 subscriptions.
        //The first one is a  normal 1 subscription listener.
        //The second one is when we want to send responses

        if (channel == null)
            throw new IllegalStateException("No channel for subscriber defined");
        if (streamId <= 0)
            throw new IllegalStateException("No stream for subscriber defined");
        if (aeron == null)
            throw new IllegalStateException("No aeron instance defined");
        boolean started = false;
        while (!started) {
            try (final Subscription subscription = aeron.addSubscription(channel, streamId)) {
                this.subscription = subscription;
                log.info("Beginning subscribe on channel " + channel + " and stream " + streamId);
                AeronUtil.subscriberLoop(new FragmentAssembler(new NDArrayFragmentHandler(ndArrayCallback)),
                                fragmentLimitCount, running, launched).accept(subscription);
                started = true;

            } catch (Exception e) {
                log.warn("Unable to connect...trying again on channel " + channel, e);
            }
        }

    }
1080314
private void waitForThread() {
        if ((this.thread != null) && this.thread.isAlive()) {
            try {
                this.thread.join();
            } catch (final InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
770815
public int waitForWindowUpdated(String windowName) {
    if (getScopeServices().getConnection() == null) {
      throw new CommunicationException(
          "waiting for a window failed because Opera is not connected.");
    }

    return getScopeServices().waitForDesktopWindowUpdated(windowName,
                                                          OperaIntervals.WINDOW_EVENT_TIMEOUT
                                                              .getMs());
  }
1296701
@Override
    public void await() throws InterruptedException {
        queueLock.lock();
        try {
            while(test()) {
                condition.await();
            }
        }
        finally {
            queueLock.unlock();
        }
    }
607334
@Override
    public void waitForFinish() throws IOException
    {
        if (future == null)
        {
            throw new IllegalStateException("not started");
        }
        try
        {
            future.get();
        }
        catch (InterruptedException | ExecutionException ex)
        {
            throw new IOException(ex);
        }
    }
502158
@Override
	public final void send(Message message, int deliveryMode, int priority, long timeToLive) throws JMSException
    {
    	if (this.destination == null)
    		throw new UnsupportedOperationException("Destination was not set at creation time");

        // Setup message fields
    	setupMessage(destination,message,deliveryMode,priority,timeToLive);
    	
    	// Handle foreign message implementations
        message = MessageTools.normalize(message);
        
    	sendToDestination(destination,false,message,deliveryMode,priority,timeToLive);
    }
600840
@Override
	public void channelActive(final ChannelHandlerContext ctx) throws Exception {
		if (this.ctx == null) {
			this.ctx = ctx;
		}

		super.channelActive(ctx);
	}
26519
@Then("^service '(.+?)' status in cluster '(.+?)' is '(suspended|running|deploying)'( in less than '(\\d+?)' seconds checking every '(\\d+?)' seconds)?")
    public void serviceStatusCheck(String service, String cluster, String status, String foo, Integer totalWait, Integer interval) throws Exception {
        String response;
        Integer i = 0;
        boolean matched;

        response = commonspec.retrieveServiceStatus(service, cluster);

        if (foo != null) {
            matched = status.matches(response);
            while (!matched && i < totalWait) {
                this.commonspec.getLogger().info("Service status not found yet after " + i + " seconds");
                i = i + interval;
                response = commonspec.retrieveServiceStatus(service, cluster);
                matched = status.matches(response);
            }
        }

        assertThat(status).as("Expected status: " + status + " doesn't match obtained one: " + response).matches(response);

    }
616170
public void launch() throws Exception {
        if (init.get())
            return;
        // Register a SIGINT handler for graceful shutdown.
        if (!init.get())
            init();

        log.info("Subscribing to " + channel + " on stream Id " + streamId);

        // Register a SIGINT handler for graceful shutdown.
        SigInt.register(() -> running.set(false));

        // Create an Aeron instance with client-provided context configuration, connect to the
        // media driver, and add a subscription for the given channel and stream using the supplied
        // dataHandler method, which will be called with new messages as they are received.
        // The Aeron and Subscription classes implement AutoCloseable, and will automatically
        // clean up resources when this try block is finished.
        //Note here that we are either creating 1 or 2 subscriptions.
        //The first one is a  normal 1 subscription listener.
        //The second one is when we want to send responses
        boolean started = false;
        int numTries = 0;
        while (!started && numTries < 3) {
            try {
                try (final Subscription subscription = aeron.addSubscription(channel, streamId)) {
                    log.info("Beginning subscribe on channel " + channel + " and stream " + streamId);
                    AeronUtil.subscriberLoop(new FragmentAssembler(NDArrayResponseFragmentHandler.builder().aeron(aeron)
                                    .context(ctx).streamId(responseStreamId).holder(ndArrayHolder).build()),
                                    fragmentLimitCount, running, launched).accept(subscription);
                    started = true;
                }


            } catch (Exception e) {
                numTries++;
                log.warn("Failed to connect..trying again", e);
            }
        }

        if (numTries >= 3)
            throw new IllegalStateException("Was unable to start responder after " + numTries + "tries");


    }
243765
public void waitForExit()
    throws IOException
  {
    Thread thread = Thread.currentThread();
    ClassLoader oldLoader = thread.getContextClassLoader();
    
    try {
      thread.setContextClassLoader(_systemManager.getClassLoader());
      
      _waitForExitService = new WaitForExitService3(this, 
                                                    _systemManager);

      _waitForExitService.waitForExit();
    } finally {
      thread.setContextClassLoader(oldLoader);
    }
  }