text:
package org.apache.hadoop.hdfs.server.namenode;

import java.io.DataInput;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.LinkedBlockingDeque;

import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.hdfs.protocol.Block;
import org.apache.hadoop.hdfs.protocol.BlockListAsLongs;
import org.apache.hadoop.hdfs.protocol.CodingMatrix;
import org.apache.hadoop.hdfs.protocol.DatanodeID;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
import org.apache.hadoop.hdfs.protocol.RegeneratingCodeMatrix;
import org.apache.hadoop.hdfs.protocol.BlockListAsLongs.BlockReportIterator;
import org.apache.hadoop.hdfs.server.common.HdfsConstants.ReplicaState;
import org.apache.hadoop.hdfs.server.protocol.BlockCommand;
import org.apache.hadoop.hdfs.server.protocol.BlockRecoveryCommand;
import org.apache.hadoop.hdfs.server.protocol.CumulusRecoveryCommand;
import org.apache.hadoop.hdfs.server.protocol.RCRecoveryCommand;
import org.apache.hadoop.hdfs.server.protocol.BlockRecoveryCommand.RecoveringBlock;
import org.apache.hadoop.hdfs.server.protocol.DatanodeProtocol;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.hdfs.DeprecatedUTF8;
import org.apache.hadoop.io.WritableUtils;

import org.apache.hadoop.hdfs.server.monitor.*;//add by xianyu

/**************************************************
 * DatanodeDescriptor tracks stats on a given DataNode, such as
 * available storage capacity, last update time, etc., and maintains a
 * set of blocks stored on the datanode.
 *
 * This data structure is internal to the namenode. It is *not* sent
 * over-the-wire to the Client or the Datanodes. Neither is it stored
 * persistently in the fsImage.
 **************************************************/
@InterfaceAudience.Private
public class DatanodeDescriptor extends DatanodeInfo {

  // Stores status of decommissioning.
  // If node is not decommissioning, do not use this object for anything.
  DecommissioningStatus decommissioningStatus = new DecommissioningStatus();

  /** Block and targets pair */
  @InterfaceAudience.Private
  @InterfaceStability.Evolving
  public static class BlockTargetPair {
    public final Block block;
    public final DatanodeDescriptor[] targets;

    BlockTargetPair(Block block, DatanodeDescriptor[] targets) {
      this.block = block;
      this.targets = targets;
    }
  }

  /** A BlockTargetPair queue. */
  private static class BlockQueue<E> {
    private final Queue<E> blockq = new LinkedList<E>();

    /** Size of the queue */
    synchronized int size() {return blockq.size();}

    /** Enqueue */
    synchronized boolean offer(E e) {
      return blockq.offer(e);
    }

    /** Dequeue */
    synchronized List<E> poll(int numBlocks) {
      if (numBlocks <= 0 || blockq.isEmpty()) {
        return null;
      }

      List<E> results = new ArrayList<E>();
      for(; !blockq.isEmpty() && numBlocks > 0; numBlocks--) {
        results.add(blockq.poll());
      }
      return results;
    }

    /**
     * Returns <tt>true</tt> if the queue contains the specified element.
     */
    boolean contains(E e) {
      return blockq.contains(e);
    }
  }

  private volatile BlockInfo blockList = null;
  private int numBlocks = 0;
  // isAlive == heartbeats.contains(this)
  // This is an optimization, because contains takes O(n) time on Arraylist
  protected boolean isAlive = false;
  protected boolean needKeyUpdate = false;

  /** A queue of blocks to be replicated by this datanode */
  private BlockQueue<BlockTargetPair> replicateBlocks = new BlockQueue<BlockTargetPair>();
  /** A queue of blocks to be recovered by this datanode */
  private BlockQueue<BlockInfoUnderConstruction> recoverBlocks =
                                new BlockQueue<BlockInfoUnderConstruction>();
  /** A set of blocks to be invalidated by this datanode */
  private Set<Block> invalidateBlocks = new TreeSet<Block>();

  private Queue<BlockInfo> cumulusRecover = new LinkedBlockingDeque<BlockInfo>();

  /* Variables for maintaining number of blocks scheduled to be written to
   * this datanode. This count is approximate and might be slightly bigger
   * in case of errors (e.g. datanode does not report if an error occurs
   * while writing the block).
   */
  private int currApproxBlocksScheduled = 0;
  private int prevApproxBlocksScheduled = 0;
  private long lastBlocksScheduledRollTime = 0;
  private static final int BLOCKS_SCHEDULED_ROLL_INTERVAL = 600*1000; //10min
  private int volumeFailures = 0;

  /** Default constructor */
  public DatanodeDescriptor() {}

  /** DatanodeDescriptor constructor
   * @param nodeID id of the data node
   */
  public DatanodeDescriptor(DatanodeID nodeID) {
	  /* add by xianyu
	  call:
	    public DatanodeDescriptor(DatanodeID nodeID,
                            long capacity,
                            long dfsUsed,
                            long remaining,
                            ServernodeCPUStatus cpuStatus,
                            ServernodeMEMStatus memStatus,
                            ServernodeNETStatus[] netStatus,
                            ServernodeIOStatus[] ioStatus,
                            int xceiverCount,
                            int failedVolumes)
	  */
	  this(nodeID, 0L, 0L, 0L,
			  //add by xianyu
			  null, null, null, null,

			  //removed by xianyu
			  /*
			  0L, 0L, 0L,
			  */
			  0, 0);  ////ww modified
  }

  /** DatanodeDescriptor constructor
   *
   * @param nodeID id of the data node
   * @param networkLocation location of the data node in network
   */
  public DatanodeDescriptor(DatanodeID nodeID,
                            String networkLocation) {
    this(nodeID, networkLocation, null);
  }

  /** DatanodeDescriptor constructor
   *
   * @param nodeID id of the data node
   * @param networkLocation location of the data node in network
   * @param hostName it could be different from host specified for DatanodeID
   */
  public DatanodeDescriptor(DatanodeID nodeID,
                            String networkLocation,
                            String hostName) {
	  /* add by xianyu
	  call:
	    public DatanodeDescriptor(DatanodeID nodeID,
                            String networkLocation,
                            String hostName,
                            long capacity,
                            long dfsUsed,
                            long remaining,
                            ServernodeCPUStatus cpuStatus,
                            ServernodeMEMStatus memStatus,
                            ServernodeNETStatus[] netStatus,
                            ServernodeIOStatus[] ioStatus,
                            int xceiverCount,
                            int failedVolumes)
	  */
	  this(nodeID, networkLocation, hostName, 0L, 0L, 0L,
			  //add by xianyu
			  null, null, null, null,

			  //removed by xianyu
			  /*
			  0L, 0L, 0L,
			  */
			  0, 0); ////ww modified
  }

  /** DatanodeDescriptor constructor
   *
   * @param nodeID id of the data node
   * @param capacity capacity of the data node
   * @param dfsUsed space used by the data node
   * @param remaining remaing capacity of the data node
   * @param xceiverCount # of data transfers at the data node
   */
  public DatanodeDescriptor(DatanodeID nodeID,
                            long capacity,
                            long dfsUsed,
                            long remaining,
                            //add by xianyu
                            ServernodeCPUStatus cpuStatus,
                            ServernodeMEMStatus memStatus,
                            ServernodeNETStatus[] netStatus,
                            ServernodeIOStatus[] ioStatus,

                            //removed by xianyu
                            /*
                            long cpuUsed,         //ww added
                            long memUsed,         //ww added
                            long ioUsed,          //ww added
                            */
                            int xceiverCount,
                            int failedVolumes) {
    super(nodeID);
    updateHeartbeat(capacity, dfsUsed, remaining,
    		//add by xianyu
    		cpuStatus, memStatus, netStatus, ioStatus,

    		//removed by xianyu
    		/*
    		cpuUsed, memUsed, ioUsed,
    		*/
    		xceiverCount, failedVolumes);
  }

  /** DatanodeDescriptor constructor
   *
   * @param nodeID id of the data node
   * @param networkLocation location of the data node in network
   * @param capacity capacity of the data node, including space used by non-dfs
   * @param dfsUsed the used space by dfs datanode
   * @param remaining remaining capacity of the data node
   * @param xceiverCount # of data transfers at the data node
   */
  public DatanodeDescriptor(DatanodeID nodeID,
                            String networkLocation,
                            String hostName,
                            long capacity,
                            long dfsUsed,
                            long remaining,
                            /******* add by xianyu *******/
                            ServernodeCPUStatus cpuStatus,
                            ServernodeMEMStatus memStatus,
                            ServernodeNETStatus[] netStatus,
                            ServernodeIOStatus[] ioStatus,
                            /*****************************/

                            //removed by xianyu
                            /*
                            long cpuUsed,    //ww added
                            long memUsed,
                            long ioUsed,
                            */
                            int xceiverCount,
                            int failedVolumes) {
    super(nodeID, networkLocation, hostName);
    updateHeartbeat(capacity, dfsUsed, remaining,
    		//add by xianyu
    		cpuStatus, memStatus, netStatus, ioStatus,

    		//removed by xianyu
    		/*
    		cpuUsed, memUsed, ioUsed,
    		*/
    		xceiverCount, failedVolumes);
  }

  /**
   * Add datanode to the block.
   * Add block to the head of the list of blocks belonging to the data-node.
   */
  boolean addBlock(BlockInfo b) {
    if(!b.addNode(this))
      return false;
    // add to the head of the data-node list
    blockList = b.listInsert(blockList, this);
    numBlocks++;
    return true;
  }

  /**
   * Remove block from the list of blocks belonging to the data-node.
   * Remove datanode from the block.
   */
  boolean removeBlock(BlockInfo b) {
    blockList = b.listRemove(blockList, this);
    if ( b.removeNode(this) ) {
      numBlocks--;
      return true;
    } else {
      return false;
    }
  }

  /**
   * Move block to the head of the list of blocks belonging to the data-node.
   */
  void moveBlockToHead(BlockInfo b) {
    blockList = b.listRemove(blockList, this);
    blockList = b.listInsert(blockList, this);
  }

  /**
   * Replace specified old block with a new one in the DataNodeDescriptor.
   *
   * @param oldBlock - block to be replaced
   * @param newBlock - a replacement block
   * @return the new block
   */
  BlockInfo replaceBlock(BlockInfo oldBlock, BlockInfo newBlock) {
    boolean done = removeBlock(oldBlock);
    assert done : "Old block should belong to the data-node when replacing";
    done = addBlock(newBlock);
    assert done : "New block should not belong to the data-node when replacing";
    return newBlock;
  }

  void resetBlocks() {
    this.capacity = 0;
    this.remaining = 0;
    this.dfsUsed = 0;

    /*** add by xianyu ***/
    this.cpuStatus = null;
    this.memStatus = null;
    this.netStatus = null;
    this.ioStatus = null;
    /********************/

    //removed by xianyu
    /*
    this.cpuUsed = 0;              //ww added
    this.memUsed = 0;              //ww added
    this.ioUsed = 0;               //ww added
    */
    this.xceiverCount = 0;
    this.blockList = null;
    this.invalidateBlocks.clear();
    this.volumeFailures = 0;
  }

  public int numBlocks() {
    return numBlocks;
  }

  /**
   * Updates stats from datanode heartbeat.
   */
  void updateHeartbeat(long capacity, long dfsUsed, long remaining,

		  /******* add by xianyu *******/
		  ServernodeCPUStatus cpuStatus,
		  ServernodeMEMStatus memStatus,
		  ServernodeNETStatus[] netStatus,
		  ServernodeIOStatus[] ioStatus,
		  /*****************************/

		  //removed by xianyu
		  /*
		  long cpuUsed, long memUsed, long ioUsed,
		  */
		  int xceiverCount, int volFailures) {
    this.capacity = capacity;
    this.dfsUsed = dfsUsed;
    this.remaining = remaining;
    /****** add by xianyu ******/
    this.cpuStatus = cpuStatus;
    this.memStatus = memStatus;
    this.netStatus = netStatus;
    this.ioStatus = ioStatus;
    /***************************/

    //removed by xianyu
    /*
    this.cpuUsed = cpuUsed;                    //ww added
    this.memUsed = memUsed;                    //ww added
    this.ioUsed = ioUsed;                      //ww adde
    */
    this.lastUpdate = System.currentTimeMillis();
    this.xceiverCount = xceiverCount;
    this.volumeFailures = volFailures;
    rollBlocksScheduled(lastUpdate);
  }

  /**
   * Iterates over the list of blocks belonging to the datanode.
   */
  static private class BlockIterator implements Iterator<BlockInfo> {
    private BlockInfo current;
    private DatanodeDescriptor node;

    BlockIterator(BlockInfo head, DatanodeDescriptor dn) {
      this.current = head;
      this.node = dn;
    }

    public boolean hasNext() {
      return current != null;
    }

    public BlockInfo next() {
      BlockInfo res = current;
      current = current.getNext(current.findDatanode(node));
      return res;
    }

    public void remove()  {
      throw new UnsupportedOperationException("Sorry. can't remove.");
    }
  }

  Iterator<BlockInfo> getBlockIterator() {
    return new BlockIterator(this.blockList, this);
  }

  /**
   * Store block replication work.
   */
  void addBlockToBeReplicated(Block block, DatanodeDescriptor[] targets) {
    assert(block != null && targets != null && targets.length > 0);
    replicateBlocks.offer(new BlockTargetPair(block, targets));
  }

  /**
   * added by czl
   * add block to recover queue
   * @param block
   */
  void addBlockToBeRecoveredCumulus(BlockInfo block){
	   cumulusRecover.offer(block);
   }

  /**
   * Store block recovery work.
   */
  void addBlockToBeRecovered(BlockInfoUnderConstruction block) {
    if(recoverBlocks.contains(block)) {
      // this prevents adding the same block twice to the recovery queue
      FSNamesystem.LOG.info("Block " + block +
                            " is already in the recovery queue.");
      return;
    }
    recoverBlocks.offer(block);
  }

  /**
   * Store block invalidation work.
   */
  void addBlocksToBeInvalidated(List<Block> blocklist) {
    assert(blocklist != null && blocklist.size() > 0);
    synchronized (invalidateBlocks) {
      for(Block blk : blocklist) {
        invalidateBlocks.add(blk);
      }
    }
  }

  /**
   * The number of work items that are pending to be replicated
   */
  int getNumberOfBlocksToBeReplicated() {
    return replicateBlocks.size();
  }

  /**
   * The number of block invalidation items that are pending to
   * be sent to the datanode
   */
  int getNumberOfBlocksToBeInvalidated() {
    synchronized (invalidateBlocks) {
      return invalidateBlocks.size();
    }
  }

  /************** add by xianyu ****************
  /**
   * The number of work items that are pending to be recovered
   */
  int getNumberOfBlocksToBeRecoved(){
	  return recoverBlocks.size();
  }

  /**
   * live or dead
   */
  boolean isAlive(){
	  return isAlive;
  }
  /***********************************************/

  /**
   * added by czl
   * @return
   */
  CumulusRecoveryCommand getCumulusRecoveryCommand(){
	  BlockInfo blockInfo = cumulusRecover.poll();
	  if (blockInfo == null) {
		return null;
	}
	  INodeFile filenode = blockInfo.getINode();
	  List<BlockTargetPair> blockTargetPairs = new ArrayList<BlockTargetPair>();
	  DatanodeDescriptor[] dnds;
	  byte lostColumn = 0;
	  byte i = 0;
	  for(BlockInfo blkInfo: filenode.getBlocks()){
	  	  dnds = new DatanodeDescriptor[1];
		  dnds[0] = blkInfo.getDatanode(0);
		  NameNode.LOG.info("hahahhhahah"+dnds[0].toString()+"    "+blkInfo.getBlockId());
		  if (blkInfo.getBlockId() == blockInfo.getBlockId()) {
			lostColumn = i;
		}
		  i++;
		  blockTargetPairs.add(new BlockTargetPair((Block)blkInfo, dnds));
	  }
	  CodingMatrix matrix = filenode.getMatrix();
	  FSNamesystem.LOG.info(lostColumn+"   .............    ");
	  return new CumulusRecoveryCommand(DatanodeProtocol.DNA_CUMULUS_RECOVERY, filenode.getType(), lostColumn, matrix, blockTargetPairs);
  }

//seq RCR_NN_APPOINTnc.2 1
	/**
	 * get rcr command, based on getCumulusRecoveryCommand(). created at 2014-4-21. modified at.
	 *
	 * @author ds
	 * @return
	 */
	RCRecoveryCommand getRCRecoveryCommand()
	{
		BlockInfo representBlockInfo = cumulusRecover.poll();
		if (representBlockInfo == null)
		{
			return null;
		}
		INodeFile filenode = representBlockInfo.getINode();
		BlockInfo[] fileBlockInfos = filenode.getBlocks();

		byte failednodeRow = 0;
		int a = ((RegeneratingCodeMatrix) filenode.getMatrix()).getA();// 4-28
		LocatedBlock[] fileLocatedBlocks = new LocatedBlock[fileBlockInfos.length];
		for (int i = 0; i < fileBlockInfos.length; i++)
		{
			BlockInfo blockInfo = fileBlockInfos[i];
			if (blockInfo.getBlockId() == representBlockInfo.getBlockId())
			{
				failednodeRow = (byte) (i / a);
			}
			DatanodeInfo datanode = blockInfo.getDatanode(0);
			LocatedBlock locatedBlock = new LocatedBlock((Block) blockInfo, new DatanodeInfo[]
			{ datanode });
			fileLocatedBlocks[i] = locatedBlock;
		}
		CodingMatrix matrix = filenode.getMatrix();
		FSNamesystem.LOG.info("failednodeRow" + failednodeRow + "   .............    ");
		return new RCRecoveryCommand(DatanodeProtocol.DNA_RC_RECOVERY, filenode.getType(), failednodeRow, matrix,
				fileLocatedBlocks);
		// test27-1 exception object cannot casted to LocatedBlock
	}

  BlockCommand getReplicationCommand(int maxTransfers) {
    List<BlockTargetPair> blocktargetlist = replicateBlocks.poll(maxTransfers);
    return blocktargetlist == null? null:
        new BlockCommand(DatanodeProtocol.DNA_TRANSFER, blocktargetlist);
  }

  BlockRecoveryCommand getLeaseRecoveryCommand(int maxTransfers) {
    List<BlockInfoUnderConstruction> blocks = recoverBlocks.poll(maxTransfers);
    if(blocks == null)
      return null;
    BlockRecoveryCommand brCommand = new BlockRecoveryCommand(blocks.size());
    for(BlockInfoUnderConstruction b : blocks) {
      brCommand.add(new RecoveringBlock(
          b, b.getExpectedLocations(), b.getBlockRecoveryId()));
    }
    return brCommand;
  }

  /**
   * Remove the specified number of blocks to be invalidated
   */
  BlockCommand getInvalidateBlocks(int maxblocks) {
    Block[] deleteList = getBlockArray(invalidateBlocks, maxblocks);
    return deleteList == null?
        null: new BlockCommand(DatanodeProtocol.DNA_INVALIDATE, deleteList);
  }

  static private Block[] getBlockArray(Collection<Block> blocks, int max) {
    Block[] blockarray = null;
    synchronized(blocks) {
      int available = blocks.size();
      int n = available;
      if (max > 0 && n > 0) {
        if (max < n) {
          n = max;
        }
        // allocate the properly sized block array ...
        blockarray = new Block[n];

        // iterate tree collecting n blocks...
        Iterator<Block> e = blocks.iterator();
        int blockCount = 0;

        while (blockCount < n && e.hasNext()) {
          // insert into array ...
          blockarray[blockCount++] = e.next();

          // remove from tree via iterator, if we are removing
          // less than total available blocks
          if (n < available){
            e.remove();
          }
        }
        assert(blockarray.length == n);

        // now if the number of blocks removed equals available blocks,
        // them remove all blocks in one fell swoop via clear
        if (n == available) {
          blocks.clear();
        }
      }
    }
    return blockarray;
  }

  void reportDiff(BlockManager blockManager,
                  BlockListAsLongs newReport,
                  Collection<Block> toAdd,    // add to DatanodeDescriptor
                  Collection<Block> toRemove, // remove from DatanodeDescriptor
                  Collection<Block> toInvalidate, // should be removed from DN
                  Collection<BlockInfo> toCorrupt) {// add to corrupt replicas
    // place a delimiter in the list which separates blocks
    // that have been reported from those that have not
    BlockInfo delimiter = new BlockInfo(new Block(), 1);
    boolean added = this.addBlock(delimiter);
    assert added : "Delimiting block cannot be present in the node";
    if(newReport == null)
      newReport = new BlockListAsLongs();
    // scan the report and process newly reported blocks
    BlockReportIterator itBR = newReport.getBlockReportIterator();
    while(itBR.hasNext()) {
      Block iblk = itBR.next();
      ReplicaState iState = itBR.getCurrentReplicaState();
      BlockInfo storedBlock = processReportedBlock(blockManager, iblk, iState,
                                               toAdd, toInvalidate, toCorrupt);
      // move block to the head of the list
      if(storedBlock != null && storedBlock.findDatanode(this) >= 0)
        this.moveBlockToHead(storedBlock);
    }
    // collect blocks that have not been reported
    // all of them are next to the delimiter
    Iterator<? extends Block> it = new BlockIterator(delimiter.getNext(0),this);
    while(it.hasNext())
      toRemove.add(it.next());
    this.removeBlock(delimiter);
  }

  /**
   * Process a block replica reported by the data-node.
   *
   * <ol>
   * <li>If the block is not known to the system (not in blocksMap) then the
   * data-node should be notified to invalidate this block.</li>
   * <li>If the reported replica is valid that is has the same generation stamp
   * and length as recorded on the name-node, then the replica location is
   * added to the name-node.</li>
   * <li>If the reported replica is not valid, then it is marked as corrupt,
   * which triggers replication of the existing valid replicas.
   * Corrupt replicas are removed from the system when the block
   * is fully replicated.</li>
   * </ol>
   *
   * @param blockManager
   * @param block reported block replica
   * @param rState reported replica state
   * @param toAdd add to DatanodeDescriptor
   * @param toInvalidate missing blocks (not in the blocks map)
   *        should be removed from the data-node
   * @param toCorrupt replicas with unexpected length or generation stamp;
   *        add to corrupt replicas
   * @return
   */
  BlockInfo processReportedBlock(
                  BlockManager blockManager,
                  Block block,                // reported block replica
                  ReplicaState rState,        // reported replica state
                  Collection<Block> toAdd,    // add to DatanodeDescriptor
                  Collection<Block> toInvalidate, // should be removed from DN
                  Collection<BlockInfo> toCorrupt) {// add to corrupt replicas
    if(FSNamesystem.LOG.isDebugEnabled()) {
      FSNamesystem.LOG.debug("Reported block " + block
          + " on " + getName() + " size " + block.getNumBytes()
          + " replicaState = " + rState);
    }

    // find block by blockId
    BlockInfo storedBlock = blockManager.blocksMap.getStoredBlock(block);
    if(storedBlock == null) {
      // If blocksMap does not contain reported block id,
      // the replica should be removed from the data-node.
      toInvalidate.add(new Block(block));
      return null;
    }

    if(FSNamesystem.LOG.isDebugEnabled()) {
      FSNamesystem.LOG.debug("In memory blockUCState = " +
          storedBlock.getBlockUCState());
    }

    // Ignore replicas already scheduled to be removed from the DN
    if(blockManager.belongsToInvalidates(getStorageID(), block)) {
      assert storedBlock.findDatanode(this) < 0 : "Block " + block
        + " in recentInvalidatesSet should not appear in DN " + this;
      return storedBlock;
    }

    // Block is on the DN
    boolean isCorrupt = false;
    switch(rState) {
    case FINALIZED:
      switch(storedBlock.getBlockUCState()) {
      case COMPLETE:
      case COMMITTED:
        if(storedBlock.getGenerationStamp() != block.getGenerationStamp()
            || storedBlock.getNumBytes() != block.getNumBytes())
          isCorrupt = true;
        break;
      case UNDER_CONSTRUCTION:
      case UNDER_RECOVERY:
        ((BlockInfoUnderConstruction)storedBlock).addReplicaIfNotPresent(
            this, block, rState);
      }
      if(!isCorrupt && storedBlock.findDatanode(this) < 0)
        if (storedBlock.getNumBytes() != block.getNumBytes()) {
          toAdd.add(new Block(block));
        } else {
          toAdd.add(storedBlock);
        }
      break;
    case RBW:
    case RWR:
      if(!storedBlock.isComplete())
        ((BlockInfoUnderConstruction)storedBlock).addReplicaIfNotPresent(
                                                      this, block, rState);
      else
        isCorrupt = true;
      break;
    case RUR:       // should not be reported
    case TEMPORARY: // should not be reported
    default:
      FSNamesystem.LOG.warn("Unexpected replica state " + rState
          + " for block: " + storedBlock +
          " on " + getName() + " size " + storedBlock.getNumBytes());
      break;
    }
    if(isCorrupt)
        toCorrupt.add(storedBlock);
    return storedBlock;
  }

  /** Serialization for FSEditLog */
  void readFieldsFromFSEditLog(DataInput in) throws IOException {
    this.name = DeprecatedUTF8.readString(in);
    this.storageID = DeprecatedUTF8.readString(in);
    this.infoPort = in.readShort() & 0x0000ffff;

    this.capacity = in.readLong();
    this.dfsUsed = in.readLong();
    this.remaining = in.readLong();

    /************** add by xianyu *********************/
    this.cpuStatus = ServernodeCPUStatus.read(in);
    this.memStatus = ServernodeMEMStatus.read(in);

    int cnt = in.readInt();
    this.netStatus = new ServernodeNETStatus[cnt];
    for(int i = 0; i < cnt; i++)
    	this.netStatus[i] = ServernodeNETStatus.read(in);

    cnt = in.readInt();
    this.ioStatus = new ServernodeIOStatus[cnt];
    for(int j = 0; j < cnt; j++)
    	this.ioStatus[j] = ServernodeIOStatus.read(in);
    /**************************************************/

    //removed by xianyu
    /*
    this.cpuUsed = in.readLong();                 //ww added
    this.memUsed = in.readLong();                 //ww added
    this.ioUsed = in.readLong();                  //ww added
    */
    this.lastUpdate = in.readLong();
    this.xceiverCount = in.readInt();
    this.location = Text.readString(in);
    this.hostName = Text.readString(in);
    setAdminState(WritableUtils.readEnum(in, AdminStates.class));
  }

  /**
   * @return Approximate number of blocks currently scheduled to be written
   * to this datanode.
   */
  public int getBlocksScheduled() {
    return currApproxBlocksScheduled + prevApproxBlocksScheduled;
  }

  /**
   * Increments counter for number of blocks scheduled.
   */
  void incBlocksScheduled() {
    currApproxBlocksScheduled++;
  }

  /**
   * Decrements counter for number of blocks scheduled.
   */
  void decBlocksScheduled() {
    if (prevApproxBlocksScheduled > 0) {
      prevApproxBlocksScheduled--;
    } else if (currApproxBlocksScheduled > 0) {
      currApproxBlocksScheduled--;
    }
    // its ok if both counters are zero.
  }

  /**
   * Adjusts curr and prev number of blocks scheduled every few minutes.
   */
  private void rollBlocksScheduled(long now) {
    if ((now - lastBlocksScheduledRollTime) >
        BLOCKS_SCHEDULED_ROLL_INTERVAL) {
      prevApproxBlocksScheduled = currApproxBlocksScheduled;
      currApproxBlocksScheduled = 0;
      lastBlocksScheduledRollTime = now;
    }
  }

  @Override
  public int hashCode() {
    // Super implementation is sufficient
    return super.hashCode();
  }

  @Override
  public boolean equals(Object obj) {
    // Sufficient to use super equality as datanodes are uniquely identified
    // by DatanodeID
    return (this == obj) || super.equals(obj);
  }

  class DecommissioningStatus {
    int underReplicatedBlocks;
    int decommissionOnlyReplicas;
    int underReplicatedInOpenFiles;
    long startTime;

    synchronized void set(int underRep,
        int onlyRep, int underConstruction) {
      if (isDecommissionInProgress() == false) {
        return;
      }
      underReplicatedBlocks = underRep;
      decommissionOnlyReplicas = onlyRep;
      underReplicatedInOpenFiles = underConstruction;
    }

    synchronized int getUnderReplicatedBlocks() {
      if (isDecommissionInProgress() == false) {
        return 0;
      }
      return underReplicatedBlocks;
    }
    synchronized int getDecommissionOnlyReplicas() {
      if (isDecommissionInProgress() == false) {
        return 0;
      }
      return decommissionOnlyReplicas;
    }

    synchronized int getUnderReplicatedInOpenFiles() {
      if (isDecommissionInProgress() == false) {
        return 0;
      }
      return underReplicatedInOpenFiles;
    }

    synchronized void setStartTime(long time) {
      startTime = time;
    }

    synchronized long getStartTime() {
      if (isDecommissionInProgress() == false) {
        return 0;
      }
      return startTime;
    }
  }  // End of class DecommissioningStatus

  /**
   * @return number of failed volumes in the datanode.
   */
  public int getVolumeFailures() {
    return volumeFailures;
  }

  /**
   * @param nodeReg DatanodeID to update registration for.
   */
  public void updateRegInfo(DatanodeID nodeReg) {
    super.updateRegInfo(nodeReg);
  }
}


text:
.avatar {
  border-radius: 50%;
}

.capitalize {
  text-transform: capitalize;
}

redpajama_set_name: RedPajamaGithub


text:
package org.apache.hadoop.security;

import java.io.*;
import java.util.HashMap;
import java.util.HashSet;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.MD5Hash;

public class UserPasswordInformation {

  public static final Log LOG = LogFactory
      .getLog(UserPasswordInformation.class);

  class RefreshUsers implements Runnable {
    public RefreshUsers() {
    }

    public void run() {
      while (true) {
        try {
          readPasswordFromFile();
          Thread.sleep(refreshTimeInterval);
        } catch (InterruptedException e) {
          break;
        } catch (IOException e) {
          LOG.error(e);
        }
      }
    }
  }

  public UserPasswordInformation(Configuration conf) {
    passwdFilePath = conf.get("user.password.file.name");
    refreshTimeInterval = conf.getLong("user.password.interval", 300000);
    lastSuccessfulRefreshTime = -1;

    RefreshUsers refreshUsers = new RefreshUsers();
    refreshUsersThread = new Thread(refreshUsers, "refreshUsers");
    refreshUsersThread.start();
  }

  public int readPasswordFromFile() throws IOException {
    if (null == passwdFilePath) {
      LOG.warn("user.password.file.name not defined.");
      return -1;
    }

    FileInputStream fis = null;
    BufferedReader br = null;
    try {

      File passwdFile = new File(passwdFilePath);
      long lastModified = passwdFile.lastModified();

      if (lastModified == lastSuccessfulRefreshTime) {
        return 0;
      }

      // if user.password.file.name modified less than 5 seconds, wait for 5
      // seconds, in case the file doesn't finished.
      long currentTime = System.currentTimeMillis();
      if (currentTime - lastModified < 5000) {
        try {
          Thread.sleep(5000);
        } catch (InterruptedException e) {
          LOG.fatal(e);
        }
      }

      fis = new FileInputStream(passwdFile);
      br = new BufferedReader(new InputStreamReader(fis));

      HashMap<String, String> tmpUser2Passwd = new HashMap<String, String>();
      HashMap<String, HashSet<String>> tmpUser2Groups = new HashMap<String, HashSet<String>>();

      String strLine;
      String[] userPassGroups;

      int cntUser = 0;
      while ((strLine = br.readLine()) != null) {
        userPassGroups = strLine.split(":"); // user:password:group1[:groupN...]

        if (userPassGroups.length < 2) {
          LOG.error("User, password and group information not complete: "
              + strLine);
          continue;
        }

        tmpUser2Passwd.put(userPassGroups[0], userPassGroups[1]);

        HashSet<String> groupsSet = new HashSet<String>();
        for (int idxUPG = 2; idxUPG < userPassGroups.length; idxUPG++) {
          groupsSet.add(userPassGroups[idxUPG]);
        }
        tmpUser2Groups.put(userPassGroups[0], groupsSet);

        cntUser += 1;
      }

      if (cntUser > 0) {
        user2Passwd = tmpUser2Passwd;
        user2Groups = tmpUser2Groups;
        lastSuccessfulRefreshTime = lastModified;
        // if user checkGroup exists and password is "true", then check group will be enable
        if (user2Passwd.containsKey("checkGroup")
            && MD5_OF_TRUE.equals(user2Passwd
                .get("checkGroup"))) {
          checkGroup = true;
          LOG
              .info("Check group enabled. Set special user checkGroup's password other from true can disable it.");
        } else {
          checkGroup = false;
          LOG
              .info("Check group disabled. Set special user checkGroup's password to true can enable it.");
        }

        LOG.info("Successfully updated user and password information.");
      }
    } catch (FileNotFoundException e) {
      LOG.fatal(e);
      return -1;
    } catch (IOException e) {
      LOG.fatal(e);
      return -1;
    } finally {
      if (null != br) {
        br.close();
      }
      if (null != fis) {
        fis.close();
      }
    }
    return 0;
  }

  public boolean checkUserAndPassword(String user, String passwd,
      String[] groups) {
    if (null == passwdFilePath) {
      return true;
    }

    if (!user2Passwd.containsKey(user)) {
      return false;
    }

    if (checkGroup) {
      HashSet<String> groupsSet = user2Groups.get(user);
      for (String group : groups) {
        if (!groupsSet.contains(group)) {
          if (!group.startsWith("cug-")) {
            continue;
          }
          LOG.info(group + " not in " + groupsSet);
          return false;
        }
      }
    }

    if ("".equals(passwd)) {
      if ("".equals(user2Passwd.get(user))) {
        return true;
      } else {
        return false;
      }
    } else {
      MD5Hash md5hs = MD5Hash.digest(passwd);

      if (!md5hs.toString().equals(user2Passwd.get(user))) {
        return false;
      }
      return true;
    }
  }

  private HashMap<String, String> user2Passwd = new HashMap<String, String>();
  private HashMap<String, HashSet<String>> user2Groups = new HashMap<String, HashSet<String>>();
  private String passwdFilePath;
  private Long refreshTimeInterval;
  private Thread refreshUsersThread;
  private long lastSuccessfulRefreshTime;
  private boolean checkGroup = false;
  private final String MD5_OF_TRUE = "b326b5062b2f0e69046810717534cb09";
}


text:
package examples;

import io.reactivex.Completable;
import io.reactivex.Flowable;
import io.reactivex.Maybe;
import io.reactivex.Observable;
import io.reactivex.Scheduler;
import io.reactivex.Single;
import io.reactivex.plugins.RxJavaPlugins;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.file.AsyncFile;
import io.vertx.core.file.FileSystem;
import io.vertx.core.file.OpenOptions;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.streams.Pump;
import io.vertx.core.streams.ReadStream;
import io.vertx.reactivex.CompletableHelper;
import io.vertx.reactivex.FlowableHelper;
import io.vertx.reactivex.MaybeHelper;
import io.vertx.reactivex.RxHelper;
import io.vertx.reactivex.SingleHelper;

import java.util.concurrent.TimeUnit;

/**
 * @author Julien Viet
 */
public class NativeExamples {

  public void toFlowable(Vertx vertx) {
    FileSystem fileSystem = vertx.fileSystem();
    fileSystem.open("/data.txt", new OpenOptions(), result -> {
      AsyncFile file = result.result();
      Flowable<Buffer> observable = FlowableHelper.toFlowable(file);
      observable.forEach(data -> System.out.println("Read data: " + data.toString("UTF-8")));
    });
  }

  private Flowable<Buffer> getFlowable() {
    throw new UnsupportedOperationException();
  }

  public void toReadStream(HttpServerResponse response) {
    Flowable<Buffer> observable = getFlowable();
    ReadStream<Buffer> readStream = FlowableHelper.toReadStream(observable);
    Pump pump = Pump.pump(readStream, response);
    pump.start();
  }

  public <T> Handler<AsyncResult<T>> getHandler() {
    throw new UnsupportedOperationException();
  }

  public void handlerToSingleObserver() {

    Handler<AsyncResult<String>> handler = getHandler();

    // Subscribe to a Single
    Single.just("hello").subscribe(SingleHelper.toObserver(handler));
  }

  public void handlerToMaybeObserver() {

    Handler<AsyncResult<String>> handler = getHandler();

    // Subscribe to a Single
    Maybe.just("hello").subscribe(MaybeHelper.toObserver(handler));
  }

  public void handlerToCompletableObserver() {

    Handler<AsyncResult<Void>> handler = getHandler();

    // Subscribe to a Single
    Completable.complete().subscribe(CompletableHelper.toObserver(handler));
  }

  public void scheduler(Vertx vertx) {
    Scheduler scheduler = RxHelper.scheduler(vertx);
    Observable<Long> timer = Observable.interval(100, 100, TimeUnit.MILLISECONDS, scheduler);
  }

  public void blockingScheduler(Vertx vertx) {
    Scheduler scheduler = RxHelper.blockingScheduler(vertx);
    Observable<Long> timer = Observable.interval(100, 100, TimeUnit.MILLISECONDS, scheduler);
  }

  public void schedulerHook(Vertx vertx) {
    RxJavaPlugins.setComputationSchedulerHandler(s -> RxHelper.scheduler(vertx));
    RxJavaPlugins.setIoSchedulerHandler(s -> RxHelper.blockingScheduler(vertx));
    RxJavaPlugins.setNewThreadSchedulerHandler(s -> RxHelper.scheduler(vertx));
  }

  private class MyPojo {
  }

  public void unmarshaller(FileSystem fileSystem) {
    fileSystem.open("/data.txt", new OpenOptions(), result -> {
      AsyncFile file = result.result();
      Flowable<Buffer> observable = FlowableHelper.toFlowable(file);
      observable.compose(FlowableHelper.unmarshaller(MyPojo.class)).subscribe(
          mypojo -> {
            // Process the object
          }
      );
    });
  }
}


text:
PrimaryAttributeSet::PrimaryAttributeSet(int raceID, bool male, Random &random)
{
	for (const PrimaryAttributeName attributeName : PRIMARY_ATTRIBUTE_NAMES)
	{
		PrimaryAttribute attribute(attributeName, raceID, male, random);
		this->attributeMap.emplace(attributeName, std::move(attribute));
	}
}

const PrimaryAttribute &PrimaryAttributeSet::get(PrimaryAttributeName attributeName) const
{
	return this->attributeMap.at(attributeName);
}

std::vector<PrimaryAttribute> PrimaryAttributeSet::getAll() const
{
	std::vector<PrimaryAttribute> attributes;

	for (const PrimaryAttributeName name : PRIMARY_ATTRIBUTE_NAMES)
	{
		const PrimaryAttribute &attribute = this->get(name);
		attributes.emplace_back(attribute);
	}

	return attributes;
}

int PrimaryAttributeSet::getValue(PrimaryAttributeName attributeName) const
{
	const PrimaryAttribute &attribute = this->get(attributeName);
	return attribute.get();
}

const PrimaryAttribute &PrimaryAttributeSet::getStrength() const
{
	return this->get(PrimaryAttributeName::Strength);
}

const PrimaryAttribute &PrimaryAttributeSet::getIntelligence() const
{
	return this->get(PrimaryAttributeName::Intelligence);
}

const PrimaryAttribute &PrimaryAttributeSet::getWillpower() const
{
	return this->get(PrimaryAttributeName::Willpower);
}

const PrimaryAttribute &PrimaryAttributeSet::getAgility() const
{
	return this->get(PrimaryAttributeName::Agility);
}

const PrimaryAttribute &PrimaryAttributeSet::getSpeed() const
{
	return this->get(PrimaryAttributeName::Speed);
}

const PrimaryAttribute &PrimaryAttributeSet::getEndurance() const
{
	return this->get(PrimaryAttributeName::Endurance);
}

const PrimaryAttribute &PrimaryAttributeSet::getPersonality() const
{
	return this->get(PrimaryAttributeName::Personality);
}

const PrimaryAttribute &PrimaryAttributeSet::getLuck() const
{
	return this->get(PrimaryAttributeName::Luck);
}


text:
require 'net/ssh/errors'
require 'net/ssh/known_hosts'
require 'net/ssh/verifiers/secure'

module Net; module SSH; module Verifiers

  # Does a strict host verification, looking the server up in the known
  # host files to see if a key has already been seen for this server. If this
  # server does not appear in any host file, this will silently add the
  # server. If the server does appear at least once, but the key given does
  # not match any known for the server, an exception will be raised (HostKeyMismatch).
  # Otherwise, this returns true.
  class Strict < Secure
    def verify(arguments)
      begin
        super
      rescue HostKeyUnknown => err
        err.remember_host!
        return true
      end
    end
  end

end; end; end


text:
      Button Recording Site

Home

About

Contact


text:
% Mesh spectrum

function [L,H,d] = mesh_spectrum(S,n,varargin)

%[L,H,d] = ct_mesh_spectrum(S,n,mode)
% Compute the mesh laplace matrix and its spectrum
% input,
% S: mesh file, it has to have a pnt and a tri field
% n: number of mesh harmonic functions
% mode: 'full' for the full graph, 'half' if you want to do the first and
% the second half independently (this is useful if your graph is composed
% by two connected components)
% output,
% L: mesh laplacian matrix
% H: matrix containing a mesh harmonic functions per column
% d: spectrum of the negative Laplacian matrix, its units are 1/space^2
% (spatial frequencies are obtained as sqrt(d))

if nargin==2||varargin{1}==1
    pnt{1} = S.pos;
    tri{1} = S.tri;
elseif varargin{1}==2
    pnt{1} = S.pos(1:end/2,:);
    tri{1} = S.tri(1:end/2,:);
    pnt{2} = S.pos(end/2+1:end,:);
    tri{2} = S.tri(end/2+1:end,:) - size(pnt{1},1);
end

for j = 1:length(pnt)
    if length(pnt)==2&&j == 1
        disp('Computing the spectrum of the the first hemisphere')
    elseif length(pnt)==2&&j == 2
        disp('Computing the spectrum of the the second hemisphere')
    end
    [L{j},~] = mesh_laplacian(pnt{j},tri{j});
    L{j} = (L{j} + L{j}')/2;
    disp('Computing the spectrum of the negative Laplacian matrix')
    [H{j},D] = eigs(L{j},n,'sm');
    d{j} = diag(D);
    disp('Diagonalization completed')
end


text:
/**************************************************************************//**
 * @file     bpwm.h
 * @version  V1.00
 * @brief    M480 series PWM driver header file
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * @copyright (C) 2016 Nuvoton Technology Corp. All rights reserved.
 *****************************************************************************/
#ifndef __BPWM_H__
#define __BPWM_H__

#ifdef __cplusplus
extern "C"
{
#endif

/** @addtogroup Standard_Driver Standard Driver
  @{
*/

/** @addtogroup BPWM_Driver BPWM Driver
  @{
*/

/** @addtogroup BPWM_EXPORTED_CONSTANTS BPWM Exported Constants
  @{
*/
#define BPWM_CHANNEL_NUM                          (6)        /*!< BPWM channel number \hideinitializer */
#define BPWM_CH_0_MASK                            (0x1UL)    /*!< BPWM channel 0 mask \hideinitializer */
#define BPWM_CH_1_MASK                            (0x2UL)    /*!< BPWM channel 1 mask \hideinitializer */
#define BPWM_CH_2_MASK                            (0x4UL)    /*!< BPWM channel 2 mask \hideinitializer */
#define BPWM_CH_3_MASK                            (0x8UL)    /*!< BPWM channel 3 mask \hideinitializer */
#define BPWM_CH_4_MASK                            (0x10UL)   /*!< BPWM channel 4 mask \hideinitializer */
#define BPWM_CH_5_MASK                            (0x20UL)   /*!< BPWM channel 5 mask \hideinitializer */

/*---------------------------------------------------------------------------------------------------------*/
/*  Counter Type Constant Definitions                                                                      */
/*---------------------------------------------------------------------------------------------------------*/
#define BPWM_UP_COUNTER                           (0UL)      /*!< Up counter type \hideinitializer */
#define BPWM_DOWN_COUNTER                         (1UL)      /*!< Down counter type \hideinitializer */
#define BPWM_UP_DOWN_COUNTER                      (2UL)      /*!< Up-Down counter type \hideinitializer */

/*---------------------------------------------------------------------------------------------------------*/
/*  Aligned Type Constant Definitions                                                                      */
/*---------------------------------------------------------------------------------------------------------*/
#define BPWM_EDGE_ALIGNED                         (1UL)      /*!< BPWM working in edge aligned type(down count) \hideinitializer */
#define BPWM_CENTER_ALIGNED                       (2UL)      /*!< BPWM working in center aligned type \hideinitializer */

/*---------------------------------------------------------------------------------------------------------*/
/*  Output Level Constant Definitions                                                                      */
/*---------------------------------------------------------------------------------------------------------*/
#define BPWM_OUTPUT_NOTHING                       (0UL)      /*!< BPWM output nothing \hideinitializer */
#define BPWM_OUTPUT_LOW                           (1UL)      /*!< BPWM output low \hideinitializer */
#define BPWM_OUTPUT_HIGH                          (2UL)      /*!< BPWM output high \hideinitializer */
#define BPWM_OUTPUT_TOGGLE                        (3UL)      /*!< BPWM output toggle \hideinitializer */

/*---------------------------------------------------------------------------------------------------------*/
/*  Synchronous Start Function Control Constant Definitions                                                */
/*---------------------------------------------------------------------------------------------------------*/
#define BPWM_SSCTL_SSRC_PWM0                      (0UL<<BPWM_SSCTL_SSRC_Pos)    /*!< Synchronous start source comes from PWM0  */
#define BPWM_SSCTL_SSRC_PWM1                      (1UL<<BPWM_SSCTL_SSRC_Pos)    /*!< Synchronous start source comes from PWM1  */
#define BPWM_SSCTL_SSRC_BPWM0                     (2UL<<BPWM_SSCTL_SSRC_Pos)    /*!< Synchronous start source comes from BPWM0 */
#define BPWM_SSCTL_SSRC_BPWM1                     (3UL<<BPWM_SSCTL_SSRC_Pos)    /*!< Synchronous start source comes from BPWM1 */

/*---------------------------------------------------------------------------------------------------------*/
/*  Trigger Source Select Constant Definitions                                                             */
/*---------------------------------------------------------------------------------------------------------*/
#define BPWM_TRIGGER_ADC_EVEN_ZERO_POINT                     (0UL)     /*!< BPWM trigger ADC while counter of even channel matches zero point \hideinitializer */
#define BPWM_TRIGGER_ADC_EVEN_PERIOD_POINT                   (1UL)     /*!< BPWM trigger ADC while counter of even channel matches period point \hideinitializer */
#define BPWM_TRIGGER_ADC_EVEN_ZERO_OR_PERIOD_POINT           (2UL)     /*!< BPWM trigger ADC while counter of even channel matches zero or period point \hideinitializer */
#define BPWM_TRIGGER_ADC_EVEN_CMP_UP_COUNT_POINT             (3UL)     /*!< BPWM trigger ADC while counter of even channel matches up count to comparator point \hideinitializer */
#define BPWM_TRIGGER_ADC_EVEN_CMP_DOWN_COUNT_POINT           (4UL)     /*!< BPWM trigger ADC while counter of even channel matches down count to comparator point \hideinitializer */
#define BPWM_TRIGGER_ADC_ODD_CMP_UP_COUNT_POINT              (8UL)     /*!< BPWM trigger ADC while counter of odd channel matches up count to comparator point \hideinitializer */
#define BPWM_TRIGGER_ADC_ODD_CMP_DOWN_COUNT_POINT            (9UL)     /*!< BPWM trigger ADC while counter of odd channel matches down count to comparator point \hideinitializer */

/*---------------------------------------------------------------------------------------------------------*/
/*  Capture Control Constant Definitions                                                                   */
/*---------------------------------------------------------------------------------------------------------*/
#define BPWM_CAPTURE_INT_RISING_LATCH             (1UL)        /*!< BPWM capture interrupt if channel has rising transition \hideinitializer */
#define BPWM_CAPTURE_INT_FALLING_LATCH            (0x100UL)    /*!< BPWM capture interrupt if channel has falling transition \hideinitializer */

/*---------------------------------------------------------------------------------------------------------*/
/*  Duty Interrupt Type Constant Definitions                                                               */
/*---------------------------------------------------------------------------------------------------------*/
#define BPWM_DUTY_INT_DOWN_COUNT_MATCH_CMP        (1 << BPWM_INTEN_CMPDIENn_Pos)   /*!< BPWM duty interrupt triggered if down count match comparator \hideinitializer */
#define BPWM_DUTY_INT_UP_COUNT_MATCH_CMP          (1 << BPWM_INTEN_CMPUIENn_Pos)   /*!< BPWM duty interrupt triggered if up down match comparator \hideinitializer */

/*---------------------------------------------------------------------------------------------------------*/
/*  Load Mode Constant Definitions                                                                         */
/*---------------------------------------------------------------------------------------------------------*/
#define BPWM_LOAD_MODE_IMMEDIATE                  (1 << BPWM_CTL0_IMMLDENn_Pos)    /*!< BPWM immediately load mode \hideinitializer */
#define BPWM_LOAD_MODE_CENTER                     (1 << BPWM_CTL0_CTRLDn_Pos)      /*!< BPWM center load mode \hideinitializer */

/*---------------------------------------------------------------------------------------------------------*/
/*  Clock Source Select Constant Definitions                                                               */
/*---------------------------------------------------------------------------------------------------------*/
#define BPWM_CLKSRC_BPWM_CLK                      (0UL)    /*!< BPWM Clock source selects to BPWM0_CLK or BPWM1_CLK \hideinitializer */
#define BPWM_CLKSRC_TIMER0                        (1UL)    /*!< BPWM Clock source selects to TIMER0 overflow \hideinitializer */
#define BPWM_CLKSRC_TIMER1                        (2UL)    /*!< BPWM Clock source selects to TIMER1 overflow \hideinitializer */
#define BPWM_CLKSRC_TIMER2                        (3UL)    /*!< BPWM Clock source selects to TIMER2 overflow \hideinitializer */
#define BPWM_CLKSRC_TIMER3                        (4UL)    /*!< BPWM Clock source selects to TIMER3 overflow \hideinitializer */

/*@}*/ /* end of group BPWM_EXPORTED_CONSTANTS */

/** @addtogroup BPWM_EXPORTED_FUNCTIONS BPWM Exported Functions
  @{
*/

/**
 * @brief Enable timer synchronous start counting function of specified channel(s)
 * @param[in] bpwm The pointer of the specified BPWM module
 * @param[in] u32ChannelMask Combination of enabled channels. This parameter is not used.
 * @param[in] u32SyncSrc Synchronous start source selection, valid values are:
 *              - \ref BPWM_SSCTL_SSRC_PWM0
 *              - \ref BPWM_SSCTL_SSRC_PWM1
 *              - \ref BPWM_SSCTL_SSRC_BPWM0
 *              - \ref BPWM_SSCTL_SSRC_BPWM1
 * @return None
 * @details This macro is used to enable timer synchronous start counting function of specified channel(s).
 * @note All channels share channel 0's setting.
 * \hideinitializer
 */
#define BPWM_ENABLE_TIMER_SYNC(bpwm, u32ChannelMask, u32SyncSrc) ((bpwm)->SSCTL = ((bpwm)->SSCTL & ~BPWM_SSCTL_SSRC_Msk) | (u32SyncSrc) | BPWM_SSCTL_SSEN0_Msk)

/**
 * @brief Disable timer synchronous start counting function of specified channel(s)
 * @param[in] bpwm The pointer of the specified BPWM module
 * @param[in] u32ChannelMask Combination of enabled channels. This parameter is not used.
 * @return None
 * @details This macro is used to disable timer synchronous start counting function of specified channel(s).
 * @note All channels share channel 0's setting.
 * \hideinitializer
 */
#define BPWM_DISABLE_TIMER_SYNC(bpwm, u32ChannelMask) ((bpwm)->SSCTL &= ~BPWM_SSCTL_SSEN0_Msk)

/**
 * @brief This macro enable BPWM counter synchronous start counting function.
 * @param[in] bpwm The pointer of the specified BPWM module
 * @return None
 * @details This macro is used to make selected BPWM0 and BPWM1 channel(s) start counting at the same time.
 *          To configure synchronous start counting channel(s) by BPWM_ENABLE_TIMER_SYNC() and BPWM_DISABLE_TIMER_SYNC().
 * \hideinitializer
 */
#define BPWM_TRIGGER_SYNC_START(bpwm) ((bpwm)->SSTRG = BPWM_SSTRG_CNTSEN_Msk)

/**
 * @brief This macro enable output inverter of specified channel(s)
 * @param[in] bpwm The pointer of the specified BPWM module
 * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel
 *                           Bit 0 represents channel 0, bit 1 represents channel 1...
 * @return None
 * \hideinitializer
 */
#define BPWM_ENABLE_OUTPUT_INVERTER(bpwm, u32ChannelMask) ((bpwm)->POLCTL = (u32ChannelMask))

/**
 * @brief This macro get captured rising data
 * @param[in] bpwm The pointer of the specified BPWM module
 * @param[in] u32ChannelNum BPWM channel number. Valid values are between 0~5
 * @return None
 * \hideinitializer
 */
#define BPWM_GET_CAPTURE_RISING_DATA(bpwm, u32ChannelNum) ((bpwm)->CAPDAT[(u32ChannelNum)].RCAPDAT)

/**
 * @brief This macro get captured falling data
 * @param[in] bpwm The pointer of the specified BPWM module
 * @param[in] u32ChannelNum BPWM channel number. Valid values are between 0~5
 * @return None
 * \hideinitializer
 */
#define BPWM_GET_CAPTURE_FALLING_DATA(bpwm, u32ChannelNum) ((bpwm)->CAPDAT[(u32ChannelNum)].FCAPDAT)

/**
 * @brief This macro mask output logic to high or low
 * @param[in] bpwm The pointer of the specified BPWM module
 * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel
 *                           Bit 0 represents channel 0, bit 1 represents channel 1...
 * @param[in] u32LevelMask Output logic to high or low
 * @return None
 * @details This macro is used to mask output logic to high or low of specified channel(s).
 * @note If u32ChannelMask parameter is 0, then mask function will be disabled.
 * \hideinitializer
 */
#define BPWM_MASK_OUTPUT(bpwm, u32ChannelMask, u32LevelMask) \
    { \
        (bpwm)->MSKEN = (u32ChannelMask); \
        (bpwm)->MSK = (u32LevelMask); \
    }

/**
 * @brief This macro set the prescaler of all channels
 * @param[in] bpwm The pointer of the specified BPWM module
 * @param[in] u32ChannelNum BPWM channel number. This parameter is not used.
 * @param[in] u32Prescaler Clock prescaler of specified channel. Valid values are between 1 ~ 0xFFF
 * @return None
 * \hideinitializer
 */
#define BPWM_SET_PRESCALER(bpwm, u32ChannelNum, u32Prescaler) ((bpwm)->CLKPSC = (u32Prescaler))

/**
 * @brief This macro set the duty of the selected channel
 * @param[in] bpwm The pointer of the specified BPWM module
 * @param[in] u32ChannelNum BPWM channel number. Valid values are between 0~5
 * @param[in] u32CMR Duty of specified channel. Valid values are between 0~0xFFFF
 * @return None
 * @note This new setting will take effect on next BPWM period
 * \hideinitializer
 */
#define BPWM_SET_CMR(bpwm, u32ChannelNum, u32CMR) ((bpwm)->CMPDAT[(u32ChannelNum)] = (u32CMR))

/**
 * @brief This macro get the duty of the selected channel
 * @param[in] bpwm The pointer of the specified BPWM module
 * @param[in] u32ChannelNum BPWM channel number. Valid values are between 0~5
 * @return None
 * \hideinitializer
 */
#define BPWM_GET_CMR(bpwm, u32ChannelNum) ((bpwm)->CMPDAT[(u32ChannelNum)])

/**
 * @brief This macro set the period of all channels
 * @param[in] bpwm The pointer of the specified BPWM module
 * @param[in] u32ChannelNum BPWM channel number. This parameter is not used.
 * @param[in] u32CNR Period of specified channel. Valid values are between 0~0xFFFF
 * @return None
 * @note This new setting will take effect on next BPWM period
 * @note BPWM counter will stop if period length set to 0
 * \hideinitializer
 */
#define BPWM_SET_CNR(bpwm, u32ChannelNum, u32CNR) ((bpwm)->PERIOD = (u32CNR))

/**
 * @brief This macro get the period of all channels
 * @param[in] bpwm The pointer of the specified BPWM module
 * @param[in] u32ChannelNum BPWM channel number. This parameter is not used.
 * @return None
 * \hideinitializer
 */
#define BPWM_GET_CNR(bpwm, u32ChannelNum) ((bpwm)->PERIOD)

/**
 * @brief This macro set the BPWM aligned type
 * @param[in] bpwm The pointer of the specified BPWM module
 * @param[in] u32ChannelMask Combination of enabled channels. This parameter is not used.
 * @param[in] u32AlignedType BPWM aligned type, valid values are:
 *              - \ref BPWM_EDGE_ALIGNED
 *              - \ref BPWM_CENTER_ALIGNED
 * @return None
 * @note All channels share channel 0's setting.
 * \hideinitializer
 */
#define BPWM_SET_ALIGNED_TYPE(bpwm, u32ChannelMask, u32AlignedType) ((bpwm)->CTL1 = (u32AlignedType))

/**
 * @brief Clear counter of channel 0
 * @param[in] bpwm The pointer of the specified BPWM module
 * @param[in] u32ChannelMask Combination of enabled channels. This parameter is not used.
 * @return None
 * @details This macro is used to clear counter of channel 0
 * \hideinitializer
 */
#define BPWM_CLR_COUNTER(bpwm, u32ChannelMask) ((bpwm)->CNTCLR = (BPWM_CNTCLR_CNTCLR0_Msk))

/**
 * @brief Set output level at zero, compare up, period(center) and compare down of specified channel(s)
 * @param[in] bpwm The pointer of the specified BPWM module
 * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel
 *                           Bit 0 represents channel 0, bit 1 represents channel 1...
 * @param[in] u32ZeroLevel output level at zero point, valid values are:
 *              - \ref BPWM_OUTPUT_NOTHING
 *              - \ref BPWM_OUTPUT_LOW
 *              - \ref BPWM_OUTPUT_HIGH
 *              - \ref BPWM_OUTPUT_TOGGLE
 * @param[in] u32CmpUpLevel output level at compare up point, valid values are:
 *              - \ref BPWM_OUTPUT_NOTHING
 *              - \ref BPWM_OUTPUT_LOW
 *              - \ref BPWM_OUTPUT_HIGH
 *              - \ref BPWM_OUTPUT_TOGGLE
 * @param[in] u32PeriodLevel output level at period(center) point, valid values are:
 *              - \ref BPWM_OUTPUT_NOTHING
 *              - \ref BPWM_OUTPUT_LOW
 *              - \ref BPWM_OUTPUT_HIGH
 *              - \ref BPWM_OUTPUT_TOGGLE
 * @param[in] u32CmpDownLevel output level at compare down point, valid values are:
 *              - \ref BPWM_OUTPUT_NOTHING
 *              - \ref BPWM_OUTPUT_LOW
 *              - \ref BPWM_OUTPUT_HIGH
 *              - \ref BPWM_OUTPUT_TOGGLE
 * @return None
 * @details This macro is used to Set output level at zero, compare up, period(center) and compare down of specified channel(s)
 * \hideinitializer
 */
#define BPWM_SET_OUTPUT_LEVEL(bpwm, u32ChannelMask, u32ZeroLevel, u32CmpUpLevel, u32PeriodLevel, u32CmpDownLevel) \
   do{ \
        int i; \
        for(i = 0; i < 6; i++) { \
            if((u32ChannelMask) & (1 << i)) { \
                (bpwm)->WGCTL0 = (((bpwm)->WGCTL0 & ~(3UL << (2 * i))) | ((u32ZeroLevel) << (2 * i))); \
                (bpwm)->WGCTL0 = (((bpwm)->WGCTL0 & ~(3UL << (BPWM_WGCTL0_PRDPCTLn_Pos + (2 * i)))) | ((u32PeriodLevel) << (BPWM_WGCTL0_PRDPCTLn_Pos + (2 * i)))); \
                (bpwm)->WGCTL1 = (((bpwm)->WGCTL1 & ~(3UL << (2 * i))) | ((u32CmpUpLevel) << (2 * i))); \
                (bpwm)->WGCTL1 = (((bpwm)->WGCTL1 & ~(3UL << (BPWM_WGCTL1_CMPDCTLn_Pos + (2 * i)))) | ((u32CmpDownLevel) << (BPWM_WGCTL1_CMPDCTLn_Pos + (2 * i)))); \
            } \
        } \
    }while(0)

/*---------------------------------------------------------------------------------------------------------*/
/* Define BPWM functions prototype                                                                          */
/*---------------------------------------------------------------------------------------------------------*/
uint32_t BPWM_ConfigCaptureChannel(BPWM_T *bpwm, uint32_t u32ChannelNum, uint32_t u32UnitTimeNsec, uint32_t u32CaptureEdge);
uint32_t BPWM_ConfigOutputChannel(BPWM_T *bpwm, uint32_t u32ChannelNum, uint32_t u32Frequency, uint32_t u32DutyCycle);
void BPWM_Start(BPWM_T *bpwm, uint32_t u32ChannelMask);
void BPWM_Stop(BPWM_T *bpwm, uint32_t u32ChannelMask);
void BPWM_ForceStop(BPWM_T *bpwm, uint32_t u32ChannelMask);
void BPWM_EnableADCTrigger(BPWM_T *bpwm, uint32_t u32ChannelNum, uint32_t u32Condition);
void BPWM_DisableADCTrigger(BPWM_T *bpwm, uint32_t u32ChannelNum);
void BPWM_ClearADCTriggerFlag(BPWM_T *bpwm, uint32_t u32ChannelNum, uint32_t u32Condition);
uint32_t BPWM_GetADCTriggerFlag(BPWM_T *bpwm, uint32_t u32ChannelNum);
void BPWM_EnableCapture(BPWM_T *bpwm, uint32_t u32ChannelMask);
void BPWM_DisableCapture(BPWM_T *bpwm, uint32_t u32ChannelMask);
void BPWM_EnableOutput(BPWM_T *bpwm, uint32_t u32ChannelMask);
void BPWM_DisableOutput(BPWM_T *bpwm, uint32_t u32ChannelMask);
void BPWM_EnableCaptureInt(BPWM_T *bpwm, uint32_t u32ChannelNum, uint32_t u32Edge);
void BPWM_DisableCaptureInt(BPWM_T *bpwm, uint32_t u32ChannelNum, uint32_t u32Edge);
void BPWM_ClearCaptureIntFlag(BPWM_T *bpwm, uint32_t u32ChannelNum, uint32_t u32Edge);
uint32_t BPWM_GetCaptureIntFlag(BPWM_T *bpwm, uint32_t u32ChannelNum);
void BPWM_EnableDutyInt(BPWM_T *bpwm, uint32_t u32ChannelNum, uint32_t u32IntDutyType);
void BPWM_DisableDutyInt(BPWM_T *bpwm, uint32_t u32ChannelNum);
void BPWM_ClearDutyIntFlag(BPWM_T *bpwm, uint32_t u32ChannelNum);
uint32_t BPWM_GetDutyIntFlag(BPWM_T *bpwm, uint32_t u32ChannelNum);
void BPWM_EnablePeriodInt(BPWM_T *bpwm, uint32_t u32ChannelNum,  uint32_t u32IntPeriodType);
void BPWM_DisablePeriodInt(BPWM_T *bpwm, uint32_t u32ChannelNum);
void BPWM_ClearPeriodIntFlag(BPWM_T *bpwm, uint32_t u32ChannelNum);
uint32_t BPWM_GetPeriodIntFlag(BPWM_T *bpwm, uint32_t u32ChannelNum);
void BPWM_EnableZeroInt(BPWM_T *bpwm, uint32_t u32ChannelNum);
void BPWM_DisableZeroInt(BPWM_T *bpwm, uint32_t u32ChannelNum);
void BPWM_ClearZeroIntFlag(BPWM_T *bpwm, uint32_t u32ChannelNum);
uint32_t BPWM_GetZeroIntFlag(BPWM_T *bpwm, uint32_t u32ChannelNum);
void BPWM_EnableLoadMode(BPWM_T *bpwm, uint32_t u32ChannelNum, uint32_t u32LoadMode);
void BPWM_DisableLoadMode(BPWM_T *bpwm, uint32_t u32ChannelNum, uint32_t u32LoadMode);
void BPWM_SetClockSource(BPWM_T *bpwm, uint32_t u32ChannelNum, uint32_t u32ClkSrcSel);
uint32_t BPWM_GetWrapAroundFlag(BPWM_T *bpwm, uint32_t u32ChannelNum);
void BPWM_ClearWrapAroundFlag(BPWM_T *bpwm, uint32_t u32ChannelNum);

/*@}*/ /* end of group BPWM_EXPORTED_FUNCTIONS */

/*@}*/ /* end of group BPWM_Driver */

/*@}*/ /* end of group Standard_Driver */

#ifdef __cplusplus
}
#endif

#endif /* __BPWM_H__ */

/*** (C) COPYRIGHT 2016 Nuvoton Technology Corp. ***/


text:
package org.carlos.jpa.reference_as_child;

import java.io.Serializable;
import java.util.Objects;

import com.google.common.base.MoreObjects;

@SuppressWarnings("serial")
public class TObjectReferenceId implements Serializable {

	public static TObjectReferenceId valueOf( String namespace, String value ) {
		TObjectReferenceId id = new TObjectReferenceId();
		id.setNamespace( namespace );
		id.setValue( value );
		return id;
	}

	private String namespace;
	private String value;

	public String getNamespace() {
		return namespace;
	}

	public void setNamespace( String namespace ) {
		this.namespace = namespace;
	}

	public String getValue() {
		return value;
	}

	public void setValue( String value ) {
		this.value = value;
	}

	@Override
	public boolean equals( Object obj ) {
		if ( obj instanceof TObjectReferenceId ) {
			TObjectReferenceId id = (TObjectReferenceId) obj;
			return Objects.equals( namespace, id.namespace ) && Objects.equals( value, id.value );
		}
		return false;
	}

	@Override
	public int hashCode() {
		return Objects.hash( namespace, value );
	}

	@Override
	public String toString() {
		return MoreObjects.toStringHelper( this )
				.add( "namespace", namespace )
				.add( "value", value )
				.toString();
	}

}


text:
import { ClientMiddleware, ClientMiddlewareParameters } from '../middleware'
import { HttpError } from '../errors'

export type RetryOnErrorMiddlewareOptions = {
  errors: number[] | number
  attempts: number
  period: number
  debug?: boolean
}

const retryOnError = async (
  options: RetryOnErrorMiddlewareOptions,
  error: Error | HttpError,
  params: ClientMiddlewareParameters
): Promise<any> => {
  const expectedErrors = new Array<number>().concat(options.errors)

  if (expectedErrors.length && error instanceof HttpError) {
    const { retryOnErrorState: { currentAttempts } = { currentAttempts: 0 } } =
      params.state ?? {}

    const isErrorExpected = expectedErrors.includes(error.code)
    const isMaxAttemptsReached = currentAttempts >= options.attempts ?? 0

    if (isErrorExpected && !isMaxAttemptsReached) {
      if (options?.debug) {
        // eslint-disable-next-line no-console
        console.warn(
          `Error code ${error.code} was expected. Attempting again #${
            currentAttempts + 1
          }/${options.attempts}.`
        )
      }

      const period = options.period

      if (period > 0) {
        await new Promise((resolve) => setTimeout(resolve, period))
      }

      params.repeat()
    } else {
      params.end(error)
    }

    return {
      ...params.state,
      retryOnErrorState: {
        currentAttempts: currentAttempts + 1,
      },
    }
  }
}

export const createRetryOnErrorMiddleware = (
  options: RetryOnErrorMiddlewareOptions
): ClientMiddleware<any> => retryOnError.bind(null, options)


text:
package com.ek.mobileapp.utils;

import android.content.Context;
import android.os.Handler;

public interface BlueToothReceive {
    public void receiveBlueToothMessage(String msg, int type);
    public Context getContext();

    public Handler getUIHandler();
}


text:
<!DOCTYPE html>

  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  <title>CodeMirror with constructor</title>

  <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.css" />

  <link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/codemirror.min.css" />
  <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/theme/blackboard.min.css">
  <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/theme/monokai.min.css">

  <link rel="stylesheet" href="example.css">

Summernote with CodeMirror

https://summernote.org/examples/#codemirror-as-codeview

  <textarea class="summernote">
Seasons coming up
</textarea>

    $(document).ready(function() {
      $('.summernote').summernote({
        height: 200,
        tabsize: 2,
        codemirror: {
          CodeMirrorConstructor: window.CodeMirror,
          mode: 'text/html',
          htmlMode: true,
          lineNumbers: true,
          theme: 'monokai'
        }
      });
    });


text:
Coursera Course Computational Neuroscience,  lecture 7.3 Sparse Coding and Predictive Coding

How to use:
```
 >octave
 >cd <dir>
 >cd regression-analysis
 >network
 >
 >cd ..
 >cd system-dynamics
 >network
```

## Regression analysis model type

Number of differential equations: ( N * S + N * M)
where: N = number of neurons, M = number of inputs, S = number of samples

The results clearly show convergence to sparseness.

Issues:
+ The implemented sparseness constraint is different from that in the lecture.
+ It is not a system dynamics model, it does not model the physics of neurons in a network

Typical results:

![alt text](https://github.com/RAvontuur/predictive-sparse-coding/blob/master/regression-analysis/result-plot.jpg "Result plot of a simulation run")

## System dynamics model type

Number of differential equations: ( N + N * M)
where: N = number of neurons, M = number of inputs

Issues:
+ It is not clear what this algorithm is doing
+ The learning capability of this algorithm is not clear
+ The effect of the sparseness constraint is not clear
+ The neurons are modelled as one single system with multiple outputs, the neurons seem to share each others hidden state

Typical results:

![alt text](https://github.com/RAvontuur/predictive-sparse-coding/blob/master/system-dynamics/result-plot.jpg "Result plot of a simulation run")


text:
package net.minidev.ovh.api.order.cart;

/**
 * Capacity of a pricing (type)
 */
public enum OvhGenericProductPricingCapacitiesEnum {
	installation("installation"),
	renew("renew"),
	upgrade("upgrade"),
	downgrade("downgrade");

	final String value;

	OvhGenericProductPricingCapacitiesEnum(String s) {
		this.value = s;
	}

	public String toString() {
		return this.value;
	}
}


text:
<?php

namespace NextFlowTest\Core\Scene;

use NextFlow\Php\Variable\AnyVariable;
use NextFlow\Core\Condition\SwitchCondition;

class SwitchConditionTest extends \PHPUnit_Framework_TestCase
{
    public function testFirstSocket()
    {
        // Arrange
        $neverAction = $this->getMock('NextFlow\Core\Action\AbstractAction', array('execute'));
        $neverAction->expects($this->never())->method('execute');

        $action = $this->getMock('NextFlow\Core\Action\AbstractAction', array('execute'));
        $action->expects($this->once())->method('execute');

        $condition = new SwitchCondition();
        $condition->bind(SwitchCondition::SOCKET_VALUE, new AnyVariable(1));
        $condition->bind(1, $action);
        $condition->bind(2, $neverAction);
        $condition->bind(3, $neverAction);

        // Act
        $condition->execute();

        // Assert
        $this->assertCount(4, $condition->getSockets());
    }

    public function testMiddleSocket()
    {
        // Arrange
        $neverAction = $this->getMock('NextFlow\Core\Action\AbstractAction', array('execute'));
        $neverAction->expects($this->never())->method('execute');

        $action = $this->getMock('NextFlow\Core\Action\AbstractAction', array('execute'));
        $action->expects($this->once())->method('execute');

        $condition = new SwitchCondition();
        $condition->bind(SwitchCondition::SOCKET_VALUE, new AnyVariable(2));
        $condition->bind(1, $neverAction);
        $condition->bind(2, $action);
        $condition->bind(3, $neverAction);

        // Act
        $condition->execute();

        // Assert
        $this->assertCount(4, $condition->getSockets());
    }

    public function testLastSocket()
    {
        // Arrange
        $neverAction = $this->getMock('NextFlow\Core\Action\AbstractAction', array('execute'));
        $neverAction->expects($this->never())->method('execute');

        $action = $this->getMock('NextFlow\Core\Action\AbstractAction', array('execute'));
        $action->expects($this->once())->method('execute');

        $condition = new SwitchCondition();
        $condition->bind(SwitchCondition::SOCKET_VALUE, new AnyVariable(3));
        $condition->bind(1, $neverAction);
        $condition->bind(2, $neverAction);
        $condition->bind(3, $action);

        // Act
        $condition->execute();

        // Assert
        $this->assertCount(4, $condition->getSockets());
    }

    public function testNoValidValue()
    {
        // Arrange
        $neverAction = $this->getMock('NextFlow\Core\Action\AbstractAction', array('execute'));
        $neverAction->expects($this->never())->method('execute');

        $condition = new SwitchCondition();
        $condition->bind(SwitchCondition::SOCKET_VALUE, new AnyVariable(4));
        $condition->bind(1, $neverAction);
        $condition->bind(2, $neverAction);
        $condition->bind(3, $neverAction);

        // Act
        $condition->execute();

        // Assert
        $this->assertCount(4, $condition->getSockets());
    }
}


text:
/**
 * @file subs-caps-menu-item.js
 */
import TextTrackMenuItem from './text-track-menu-item.js';
import Component from '../../component.js';
import {assign} from '../../utils/obj';

/**
 * SubsCapsMenuItem has an [cc] icon to distinguish captions from subtitles
 * in the SubsCapsMenu.
 *
 * @extends TextTrackMenuItem
 */
class SubsCapsMenuItem extends TextTrackMenuItem {

  createEl(type, props, attrs) {
    let innerHTML = `<span class="vjs-menu-item-text">${this.localize(this.options_.label)}`;

    if (this.options_.track.kind === 'captions') {
      innerHTML += `

         ${this.localize('Captions')}
      `;
    }

    innerHTML += '';

    const el = super.createEl(type, assign({
      innerHTML
    }, props), attrs);

    return el;
  }
}

Component.registerComponent('SubsCapsMenuItem', SubsCapsMenuItem);
export default SubsCapsMenuItem;


text:
package ca.uhn.fhir.rest.server.interceptor;

public interface ISecurityOutcome {

}


text:
<bill session="110" type="hj" number="98" updated="2009-01-08T16:40:06-05:00">
	<status><introduced date="1221710400" datetime="2008-09-18"/></status>

	<introduced date="1221710400" datetime="2008-09-18"/>
	<titles>
		<title type="official" as="introduced">Proposing an amendment to the Constitution of the United States to limit the number of times Senators and Representatives may be elected.</title>
	</titles>
	<sponsor id="400642"/>
	<cosponsors>

	</cosponsors>
	<actions>
		<action date="1221710400" datetime="2008-09-18"><text>Referred to the House Committee on the Judiciary.</text></action>
	</actions>
	<committees>

	</committees>
	<relatedbills>

	</relatedbills>
	<subjects>

	</subjects>
	<amendments>

	</amendments>

	9/18/2008--Introduced.
Constitutional Amendment - Limits Members of the House of Representatives to six terms and Members of the Senate to two terms.

</bill>


text: """Common GCP Types for Testing."""


text:
package com.hits.modules.sys.bean;

import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Table;
import org.nutz.dao.entity.annotation.Name;
/**
* @author frigyes
* @time   2015-06-30 19:29:25
*/
@Table("DIC_VALUE")
public class Dic_value
{
	@Column
	@Name
	private String id;
	@Column
	private String typeid;
	@Column
	private String flcode;
	@Column
	private String name;
	@Column
	private String code;
	@Column
	private String value;
	@Column
	private String pic;
	@Column
	private int state;
	@Column
	private String bz;
	@Column
	private int location;
		public String getId()
	{
		return id;
	}
	public void setId(String id)
	{
		this.id=id;
	}
	public String getTypeid()
	{
		return typeid;
	}
	public void setTypeid(String typeid)
	{
		this.typeid=typeid;
	}
	public String getFlcode()
	{
		return flcode;
	}
	public void setFlcode(String flcode)
	{
		this.flcode=flcode;
	}
	public String getName()
	{
		return name;
	}
	public void setName(String name)
	{
		this.name=name;
	}
	public String getCode()
	{
		return code;
	}
	public void setCode(String code)
	{
		this.code=code;
	}
	public String getValue()
	{
		return value;
	}
	public void setValue(String value)
	{
		this.value=value;
	}
	public String getPic()
	{
		return pic;
	}
	public void setPic(String pic)
	{
		this.pic=pic;
	}
	public int getState()
	{
		return state;
	}
	public void setState(int state)
	{
		this.state=state;
	}
	public String getBz()
	{
		return bz;
	}
	public void setBz(String bz)
	{
		this.bz=bz;
	}
	public int getLocation()
	{
		return location;
	}
	public void setLocation(int location)
	{
		this.location=location;
	}

}