<p>
Converts a FailureScope into a serialized form (a byte sequence)
</p>

@param failureScope The target FailureScope

@return byte[] A serialiazed form of the FailureScope.
339996
public byte[] toByteArray(FailureScope failureScope)
    {
        if (tc.isEntryEnabled()) Tr.entry(tc, "toByteArray", new Object[] {failureScope, this});
        
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final DataOutputStream dos = new DataOutputStream(baos);
        
        byte[] bytes = null;
        
        try
        {
            dos.writeByte(FailureScopeFactory.FILE_FAILURE_SCOPE_ID.byteValue());
            dos.writeByte(VERSION);
            dos.writeUTF(failureScope.serverName());
            dos.flush();
            dos.close();            
            bytes = baos.toByteArray();
        }
        catch (IOException ioe)
        {
            FFDCFilter.processException(ioe, "com.ibm.ws.recoverylog.spi.FileFailureScopeFactory.toByteArray", "104", this);
            if (tc.isEventEnabled()) Tr.event(tc, "IOException caught deflating failure scope", ioe);
            
            // REQD Throw an exception here, or leave method to return null?    
        }
        
        if (tc.isEntryEnabled()) Tr.exit(tc, "toByteArray", bytes);
        return bytes;
    }
329968
public static byte[] serialize(FastSerializable object) throws IOException {
        FastSerializer out = new FastSerializer();
        object.writeExternal(out);
        return out.getBBContainer().b().array();
    }
407352
public String getFailureStackAsString() {
        StringBuilder builder = new StringBuilder();
        
        for (FailureStackElement failureStackElement : getFailureStack()) {
            builder.append("\n\t");
            builder.append(failureStackElement.getStackMessage());
        }
        
        return builder.toString();
    }
554329
public static final byte[] serialize(Serializable serializable) throws IOException {
	
		if (serializable == null) {
			return null;
		}
		
		ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
		ObjectOutputStream objectOutputStream = null;
		byte[] result = null;

		if (null != _instance ){
			SerializationService ss = _instance.serializationServiceRef.getService();
			if (null != ss){
				objectOutputStream = ss.createObjectOutputStream(byteArrayOutputStream);
			}
		} 
		
		if (null == objectOutputStream){
			objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
		}
		
		try {
			objectOutputStream.writeObject(serializable);
			result = byteArrayOutputStream.toByteArray();
		} finally {

			if (byteArrayOutputStream != null) {
				byteArrayOutputStream.close();
			}
			if (objectOutputStream != null) {
				objectOutputStream.close();
			}
		}

		return result;
	}
507025
public void setFailureReason(java.util.Collection<String> failureReason) {
        if (failureReason == null) {
            this.failureReason = null;
            return;
        }

        this.failureReason = new java.util.ArrayList<String>(failureReason);
    }
64881
@Override
    public void directInitialization(FailureScope failureScope) throws RecoveryFailedException {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "directInitialization", new Object[] { failureScope, this });

        // Use configuration to determine if recovery is local (for z/OS).
        final FailureScope currentFailureScope = Configuration.localFailureScope(); /* @LI1578-22A */

        // Synchronize to ensure consistency with the registerService
        // method. The remainder of the method is not synchronized on this in order that two independant
        // recovery processes may be driven concurrently on two different threads.
        synchronized (_registeredRecoveryAgents) {
            // Ensure that further RecoveryAgent registrations are prohibited.
            _registrationAllowed = false;
        }

        if (currentFailureScope.equals(failureScope)) /* @LI1578-22C */
        {
            Tr.info(tc, "CWRLS0010_PERFORM_LOCAL_RECOVERY", failureScope.serverName());
        } else {
            Tr.info(tc, "CWRLS0011_PERFORM_PEER_RECOVERY", failureScope.serverName());
        }

        // Extract the 'values' collection from the _registeredRecoveryAgents map and create an iterator
        // from it. This iterator will return ArrayList objects each containing a set of RecoveryAgent
        // objects. Each ArrayList corrisponds to a different sequence priority value.
        final Collection registeredRecoveryAgentsValues = _registeredRecoveryAgents.values();

        Iterator registeredRecoveryAgentsValuesIterator = registeredRecoveryAgentsValues.iterator();
        while (registeredRecoveryAgentsValuesIterator.hasNext()) {
            // Extract the next ArrayList and create an iterator from it. This iterator will return RecoveryAgent
            // objects that are registered at the same sequence priority value.
            final ArrayList registeredRecoveryAgentsArray = (java.util.ArrayList) registeredRecoveryAgentsValuesIterator.next();
            final Iterator registeredRecoveryAgentsArrayIterator = registeredRecoveryAgentsArray.iterator();

            while (registeredRecoveryAgentsArrayIterator.hasNext()) {
                // Extract the next RecoveryAgent object
                final RecoveryAgent recoveryAgent = (RecoveryAgent) registeredRecoveryAgentsArrayIterator.next();
                recoveryAgent.prepareForRecovery(failureScope);

                // Prepare the maps for the recovery event.
                addInitializationRecord(recoveryAgent, failureScope);
                addRecoveryRecord(recoveryAgent, failureScope);
            }
        }

        // This is the opportunity to kick off any Network Parition Detection logic that we deem necessary. Right
        // now we are relying on the Hardware quorum support within the HA framework itself if NP's are tro be
        // handled.

        if (Configuration.HAEnabled()) {
            // Join the "dynamic cluster" in order that IOR references can be associated with the
            // resulting identity. Only do this in an HA-enabled environment.
            Configuration.getRecoveryLogComponent().joinCluster(failureScope);
        }

        // If callbacks are registered, drive then now.
        if (_registeredCallbacks != null) {
            driveCallBacks(CALLBACK_RECOVERYSTARTED, failureScope);
        }

        // Re-set the iterator.
        registeredRecoveryAgentsValuesIterator = registeredRecoveryAgentsValues.iterator();

        while (registeredRecoveryAgentsValuesIterator.hasNext()) {
            // Extract the next ArrayList and create an iterator from it. This iterator will return RecoveryAgent
            // objects that are registered at the same sequence priority value.
            final ArrayList registeredRecoveryAgentsArray = (java.util.ArrayList) registeredRecoveryAgentsValuesIterator.next();
            final Iterator registeredRecoveryAgentsArrayIterator = registeredRecoveryAgentsArray.iterator();

            while (registeredRecoveryAgentsArrayIterator.hasNext()) {
                // Extract the next RecoveryAgent object
                final RecoveryAgent recoveryAgent = (RecoveryAgent) registeredRecoveryAgentsArrayIterator.next();

                // Direct the RecoveryAgent instance to process this failure scope.
                try {
                    // Notify the listeners we're about to make the call
                    _eventListeners.clientRecoveryInitiated(failureScope, recoveryAgent.clientIdentifier()); /* @MD19638A */

                    recoveryAgent.initiateRecovery(failureScope);
                } catch (RecoveryFailedException exc) {
                    FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.RecoveryDirectorImpl.directInitialization", "410", this);
                    if (tc.isEntryEnabled())
                        Tr.exit(tc, "directInitialization", exc);
                    throw exc;
                }

                // Wait for 'serialRecoveryComplete' to be called. This callback may be issued from another thread.
                synchronized (_outstandingInitializationRecords) {
                    while (initializationOutstanding(recoveryAgent, failureScope)) {
                        try {
                            _outstandingInitializationRecords.wait();
                        } catch (InterruptedException exc) {
                            // This exception is recieved if another thread interrupts this thread by calling this threads
                            // Thread.interrupt method. The RecoveryDirectorImpl class does not use this mechanism for
                            // breaking out of the wait call - it uses notifyAll to wake up all waiting threads. This
                            // exception should never be generated. If for some reason it is called then ignore it and
                            //start to wait again.
                            FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.RecoveryDirectorImpl.directInitialization", "432", this);
                        }
                    }
                }
            }
        }

        if (currentFailureScope.equals(failureScope)) /* @LI1578-22C */
        {
            Tr.info(tc, "CWRLS0012_DIRECT_LOCAL_RECOVERY", failureScope.serverName());
        } else {
            Tr.info(tc, "CWRLS0013_DIRECT_PEER_RECOVERY", failureScope.serverName());
        }

        if (tc.isEntryEnabled())
            Tr.exit(tc, "directInitialization");
    }
158156
public java.util.List<Evaluation> getFailedEvaluations() {
        if (failedEvaluations == null) {
            failedEvaluations = new com.amazonaws.internal.SdkInternalList<Evaluation>();
        }
        return failedEvaluations;
    }
1145969
public static byte[] toBytes(CharSequence seq) {
    try {
      return seq.toString().getBytes("UTF-8");
    }
    catch (UnsupportedEncodingException ex) {
      throw new RuntimeException(ex); // shouldn't happen since UTF-8 is supported by all JVMs per spec
    }
  }
334198
public static byte[] fromBinaryCollection(Collection<Binary> binaryList) throws IOException {
        try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
             BigEndianBinaryWriter writer = new BigEndianBinaryWriter(baos)) {
            writer.writeInt(binaryList.size());
            for (Binary binary : binaryList) {
                writer.writeInt(binary.length());
                writer.writeBinary(binary);
            }
            return baos.toByteArray();
        }
    }
277181
public List<Failure> checkResolvedFailures() {
        List<Failure> fullList = new ArrayList<Failure>();

        fullList.addAll(super.checkResolvedFailures());

        for (Scenario scenario : this.scenarios.keySet()) {
            fullList.addAll(scenario.checkResolvedFailures());
        }

        return fullList;
    }
1170034
public static byte[] convertObjectToByteArray(Object o) throws IOException{
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		ObjectOutputStream oos = new ObjectOutputStream(bos);
		oos.writeObject(o);
		
		return bos.toByteArray();
	}
268301
public static <R> MethodResult<R> failure(Throwable failure) {
        return new MethodResult<>(null, failure, false);
    }
922169
public java.util.List<BatchResultErrorEntry> getFailed() {
        if (failed == null) {
            failed = new com.amazonaws.internal.SdkInternalList<BatchResultErrorEntry>();
        }
        return failed;
    }
1330589
public byte[] toByteArray() {
    try {
      final byte[] result = new byte[getSerializedSize()];
      final CodedOutputStream output = CodedOutputStream.newInstance(result);
      writeTo(output);
      output.checkNoSpaceLeft();
      return result;
    } catch (final IOException e) {
      throw new RuntimeException(
        "Serializing to a byte array threw an IOException " +
        "(should never happen).", e);
    }
  }
1294135
public static <T> CompletableFuture<T> failed(Throwable throwable) {

        LettuceAssert.notNull(throwable, "Throwable must not be null");

        CompletableFuture<T> future = new CompletableFuture<>();
        future.completeExceptionally(throwable);

        return future;
    }
420093
public S handle(Class<? extends Throwable>... failures) {
    Assert.notNull(failures, "failures");
    Assert.isTrue(failures.length > 0, "Failures cannot be empty");
    return handle(Arrays.asList(failures));
  }
1187557
public static byte[] getAsByteArray(TransactionChangesLog dataChangesLog) throws IOException
   {
      ByteArrayOutputStream os = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(os);
      oos.writeObject(dataChangesLog);

      byte[] bArray = os.toByteArray();
      return bArray;
   }