text:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
	<!--      table information
		Generate time : 2009-07-30 10:55:06
   		Version :  1.0.1.V20070717
		tableName :CG.V_STD_RPT_CONTRACT_PUTIN
		 PUTIN_DATE  VARCHAR2,
		 CONTRACT_SUBID  VARCHAR2,
		 WPROVIDER_ID  VARCHAR2,
		 WPROVIDER_NAME  VARCHAR2,
		 PRODUCT_ID  VARCHAR2,
		 PROD_TYPE_DESC  VARCHAR2,
		 SHOPSIGN  VARCHAR2,
		 SPEC  VARCHAR2,
		 PRODUCING_AREA_NAME  VARCHAR2,
		 TECH_STANDARD  VARCHAR2,
		 Q_GRADE  VARCHAR2   NOT NULL,
		 PUTIN_WEIGHT  NUMBER,
		 PUTIN_QTY  NUMBER,
		 HANDLER  VARCHAR2,
		 PUTIN_TYPE  VARCHAR2,
		 CODE_DESC  VARCHAR2   NOT NULL,
		 PUTIN_ID  VARCHAR2   NOT NULL,
		 PROVIDER_PUTOUT_ID  VARCHAR2,
		 LOCATION  VARCHAR2,
		 PROVIDER_ID  VARCHAR2,
		 PROVIDER_NAME  VARCHAR2,
		 SEG_NO  VARCHAR2   NOT NULL,
		 PRODUCT_TYPE_ID  VARCHAR2   NOT NULL,
		 PRODUCING_AREA_CODE  VARCHAR2   NOT NULL
	-->
<sqlMap namespace="STRP0102">

	<select id="query" parameterClass="java.util.HashMap"
			resultClass="com.baosight.sts.st.rp.domain.STRP0102">
		SELECT
        p.PUTIN_DATE  as "putinDate",
        p.CONTRACT_SUBID  as "contractSubid",
        p.WPROVIDER_ID  as "wproviderId",
        p.WPROVIDER_NAME  as "wproviderName",
        p.PRODUCT_ID  as "productId",
        p.PROD_TYPE_DESC  as "prodTypeDesc",
        p.SHOPSIGN  as "shopsign",
        p.SPEC  as "spec",
        p.PRODUCING_AREA_NAME  as "producingAreaName",
        p.TECH_STANDARD  as "techStandard",
        p.Q_GRADE  as "q_grade",
        nvl(p.PUTIN_WEIGHT,0)  as "putinWeight",
        nvl(p.PUTIN_QTY,0)  as "putinQty",
        p.HANDLER  as "handler",
        p.USER_ID as "userId",
        p.PUTIN_TYPE  as "putinType",
        p.CODE_DESC  as "codeDesc",
        p.PUTIN_ID  as "putinId",
        p.PROVIDER_PUTOUT_ID  as "providerPutoutId",
        p.LOCATION  as "location",
        p.PROVIDER_ID  as "providerId",
        p.PROVIDER_NAME  as "providerName",
        p.SEG_NO  as "segNo",
        p.PRODUCT_TYPE_ID  as "productTypeId",
        p.PRODUCING_AREA_CODE  as "producingAreaCode" ,
				p.STOVE_NUM	as "stove_num",
				p.PACK_ID		as	"packId",
        p.provider_contract_subnum as "providercontractsubnum",
        p.pur_price_at as "purPriceAt",<!--20140916litao加入采购单价-->
        p.factory_product_id as "factoryProductId", <!--20140916litao加入钢厂资源号-->
        p.total_amount  as  "totalAmount",<!--20140916lt采购入库金额-->
        p.remark  as  "remark",<!--20141022litao采购子项备注-->
        p.FLOWER_FLAG as "flowerFlag",
        p.ZINC as "zinc",
        p.SURFACE as "surface",
        p.AFTER_DO as "afterDo",
        decode(p.is_settle_flag,'0','否','1','是') as "isSettleFlag",
        p.SETTLE_DATE as "settleDate", <!-- 结算日期 -->
        p.Invoice_Date as "invoiceDate"<!-- 发票日期 -->
		FROM CG.V_STD_RPT_CONTRACT_PUTIN P
        WHERE 1=1
		<isNotEmpty prepend=" AND " property="segNo">
				p.SEG_NO = #segNo#
		 </isNotEmpty>
		<isNotEmpty prepend=" AND " property="contractId">
				p.CONTRACT_SUBID like '%$contractId$%'
		</isNotEmpty>
        <isNotEmpty prepend=" AND " property="codeDesc">
				p.code_desc like '%' || #codeDesc# || '%'
		</isNotEmpty>
        <isNotEmpty prepend=" AND " property="providercontractsubnum">
				p.provider_contract_subnum like '%' || #providercontractsubnum# || '%'
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="stove_num">
				p.STOVE_NUM like '%$stove_num$%'
		 </isNotEmpty>
		 <isNotEmpty prepend=" AND " property="providerId">
				(p.PROVIDER_ID = #providerId# or p.PROVIDER_NAME = #providerId#)
		 </isNotEmpty>
		<isNotEmpty prepend=" AND " property="providerPutoutId">
				p.PROVIDER_PUTOUT_ID like '%$providerPutoutId$%'
		 </isNotEmpty>
		<isNotEmpty prepend=" AND " property="putinId">
				p.PUTIN_ID = #putinId#
		 </isNotEmpty>
		<isNotEmpty prepend=" AND " property="productTypeId">
				p.PRODUCT_TYPE_ID like '%$productTypeId$%'
		 </isNotEmpty>
		 <isNotEmpty prepend=" AND " property="producingAreaCode">
				p.PRODUCING_AREA_CODE like '%$producingAreaCode$%'
		 </isNotEmpty>
		<isNotEmpty prepend=" AND " property="spec">
				p.SPEC like '%$spec$%'
		 </isNotEmpty>

		<isNotEmpty prepend=" AND " property="shopsign">
				p.SHOPSIGN like '%$shopsign$%'
		 </isNotEmpty>
		 <isNotEmpty prepend=" AND " property="wproviderId">
				p.WPROVIDER_ID = #wproviderId#
		 </isNotEmpty>
		 <isNotEmpty prepend=" AND " property="providerId">
				p.providerId = #providerId#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="startDate">
				p.PUTIN_DATE  >= #startDate#
		 </isNotEmpty>
		<isNotEmpty prepend=" AND " property="endDate">
				p.PUTIN_DATE <= #endDate#
		</isNotEmpty>
        <isNotEmpty prepend=" AND " property="purDateA">
				p.pur_date  >= #purDateA#
		 </isNotEmpty>
		<isNotEmpty prepend=" AND " property="purDateB">
				p.pur_date <= #purDateB#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="persNo">
				p.USER_ID = #persNo#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="deptNo">
				p.USER_ID = #deptNo#
		</isNotEmpty>
			<dynamic prepend="ORDER BY">
         <isNotEmpty property="orderBy">
    		  $orderBy$
   		 </isNotEmpty>
		<isEmpty property="orderBy">
    		  p.PUTIN_ID
		</isEmpty>
  		</dynamic>
	</select>
	<select id="totalquery" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
		SELECT
	       nvl(sum(p.PUTIN_WEIGHT), 0) as "putinWeight",
	       nvl(sum(p.PUTIN_QTY), 0) as "putinQty" ,
           nvl(sum(p.total_amount), 0) as "totalAmount"
	  FROM CG.V_STD_RPT_CONTRACT_PUTIN p
	 WHERE 1 = 1
		<isNotEmpty prepend=" AND " property="segNo">
				p.SEG_NO = #segNo#
		 </isNotEmpty>
		<isNotEmpty prepend=" AND " property="contractId">
				p.CONTRACT_SUBID like '%$contractId$%'
		</isNotEmpty>
        <isNotEmpty prepend=" AND " property="codeDesc">
				p.code_desc like '%' || #codeDesc# || '%'
		</isNotEmpty>
        <isNotEmpty prepend=" AND " property="providercontractsubnum">
				p.provider_contract_subnum like '%' || #providercontractsubnum# || '%'
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="stove_num">
				p.STOVE_NUM like '%$stove_num$%'
		 </isNotEmpty>
		 <isNotEmpty prepend=" AND " property="providerId">
				(p.PROVIDER_ID = #providerId# or p.PROVIDER_NAME = #providerId#)
		 </isNotEmpty>
		<isNotEmpty prepend=" AND " property="providerPutoutId">
				p.PROVIDER_PUTOUT_ID like '%$providerPutoutId$%'
		 </isNotEmpty>

		<isNotEmpty prepend=" AND " property="productTypeId">
				p.PRODUCT_TYPE_ID like '%$productTypeId$%'
		 </isNotEmpty>
		 <isNotEmpty prepend=" AND " property="producingAreaCode">
				p.PRODUCING_AREA_CODE like '%$producingAreaCode$%'
		 </isNotEmpty>
		<isNotEmpty prepend=" AND " property="spec">
				p.SPEC like '%$spec$%'
		 </isNotEmpty>

		<isNotEmpty prepend=" AND " property="shopsign">
				p.SHOPSIGN like '%$shopsign$%'
		 </isNotEmpty>
		 <isNotEmpty prepend=" AND " property="wproviderId">
				p.WPROVIDER_ID = #wproviderId#
		 </isNotEmpty>

		<isNotEmpty prepend=" AND " property="startDate">
				p.PUTIN_DATE  >= #startDate#
		 </isNotEmpty>
		<isNotEmpty prepend=" AND " property="endDate">
				p.PUTIN_DATE <= #endDate#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="persNo">
				p.USER_ID = #persNo#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="deptNo">
				p.USER_ID = #deptNo#
		</isNotEmpty>
	</select>
	<!--
		<isNotEmpty prepend=" AND " property="putinDate">
			PUTIN_DATE = #putinDate#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="wproviderId">
			WPROVIDER_ID = #wproviderId#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="wproviderName">
			WPROVIDER_NAME = #wproviderName#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="productId">
			PRODUCT_ID = #productId#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="prodTypeDesc">
			PROD_TYPE_DESC = #prodTypeDesc#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="shopsign">
			SHOPSIGN = #shopsign#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="spec">
			SPEC = #spec#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="producingAreaName">
			PRODUCING_AREA_NAME = #producingAreaName#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="techStandard">
			TECH_STANDARD = #techStandard#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="q_grade">
			Q_GRADE = #q_grade#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="putinWeight">
			PUTIN_WEIGHT = #putinWeight#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="putinQty">
			PUTIN_QTY = #putinQty#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="handler">
			HANDLER = #handler#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="putinType">
			PUTIN_TYPE = #putinType#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="codeDesc">
			CODE_DESC = #codeDesc#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="putinId">
			PUTIN_ID = #putinId#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="providerPutoutId">
			PROVIDER_PUTOUT_ID = #providerPutoutId#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="location">
			LOCATION = #location#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="providerId">
			PROVIDER_ID = #providerId#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="providerName">
			PROVIDER_NAME = #providerName#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="segNo">
			SEG_NO = #segNo#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="productTypeId">
			PRODUCT_TYPE_ID = #productTypeId#
		</isNotEmpty>
		<isNotEmpty prepend=" AND " property="producingAreaCode">
			PRODUCING_AREA_CODE = #producingAreaCode#
		</isNotEmpty>
	-->

	<insert id="insert">
		INSERT INTO CG.V_STD_RPT_CONTRACT_PUTIN (PUTIN_DATE,
										CONTRACT_SUBID,
										WPROVIDER_ID,
										WPROVIDER_NAME,
										PRODUCT_ID,
										PROD_TYPE_DESC,
										SHOPSIGN,
										SPEC,
										PRODUCING_AREA_NAME,
										TECH_STANDARD,
										Q_GRADE,
										PUTIN_WEIGHT,
										PUTIN_QTY,
										HANDLER,
										PUTIN_TYPE,
										CODE_DESC,
										PUTIN_ID,
										PROVIDER_PUTOUT_ID,
										LOCATION,
										PROVIDER_ID,
										PROVIDER_NAME,
										SEG_NO,
										PRODUCT_TYPE_ID,
										PRODUCING_AREA_CODE
										)
		VALUES (#putinDate:VARCHAR#, #contractSubid:VARCHAR#, #wproviderId:VARCHAR#, #wproviderName:VARCHAR#, #productId:VARCHAR#, #prodTypeDesc:VARCHAR#, #shopsign:VARCHAR#, #spec:VARCHAR#, #producingAreaName:VARCHAR#, #techStandard:VARCHAR#, #q_grade:VARCHAR#, #putinWeight:NUMERIC#, #putinQty:NUMERIC#, #handler:VARCHAR#, #putinType:VARCHAR#, #codeDesc:VARCHAR#, #putinId:VARCHAR#, #providerPutoutId:VARCHAR#, #location:VARCHAR#, #providerId:VARCHAR#, #providerName:VARCHAR#, #segNo:VARCHAR#, #productTypeId:VARCHAR#, #producingAreaCode:VARCHAR#)
	</insert>

	<delete id="delete">
		DELETE FROM CG.V_STD_RPT_CONTRACT_PUTIN WHERE
	</delete>

	<update id="update">
		UPDATE CG.V_STD_RPT_CONTRACT_PUTIN
		SET
		PUTIN_DATE	= #putinDate#,
					CONTRACT_SUBID	= #contractSubid#,
					WPROVIDER_ID	= #wproviderId#,
					WPROVIDER_NAME	= #wproviderName#,
					PRODUCT_ID	= #productId#,
					PROD_TYPE_DESC	= #prodTypeDesc#,
					SHOPSIGN	= #shopsign#,
					SPEC	= #spec#,
					PRODUCING_AREA_NAME	= #producingAreaName#,
					TECH_STANDARD	= #techStandard#,
					Q_GRADE	= #q_grade#,
					PUTIN_WEIGHT	= #putinWeight:NUMERIC#,
					PUTIN_QTY	= #putinQty:NUMERIC#,
					HANDLER	= #handler#,
					PUTIN_TYPE	= #putinType#,
					CODE_DESC	= #codeDesc#,
					PUTIN_ID	= #putinId#,
					PROVIDER_PUTOUT_ID	= #providerPutoutId#,
					LOCATION	= #location#,
					PROVIDER_ID	= #providerId#,
					PROVIDER_NAME	= #providerName#,
					SEG_NO	= #segNo#,
					PRODUCT_TYPE_ID	= #productTypeId#,
					PRODUCING_AREA_CODE	= #producingAreaCode#
			WHERE
	</update>

</sqlMap>


text:
void vector_commsampler::init(double t,...) {
//The 'parameters' variable contains the parameters transferred from the editor.
va_list parameters;
va_start(parameters,t);
//To get a parameter: %Name% = va_arg(parameters,%Type%)
//where:
//      %Name% is the parameter name
//	%Type% is the parameter type

char *fvar= va_arg(parameters,char*);
N=getScilabVar(fvar );

       D0 = new Coupling("CoupledCommSampler");
        Simulator **D1 = new Simulator* [N];
        Connection **EIC1 = new Connection* [0];
        Connection **EOC1 = new Connection* [0];
        Connection **IC1 = new Connection* [0];
        for (int i=0;i<N;i++){
        	D1[i] = new command_sampler("Commsampleri");

        	D1[i]->init(t);
    		}
      D0->setup(D1,N,IC1,0,EIC1,0,EOC1,0);
      D0->init(t);
}
double vector_commsampler::ta(double t) {
//This function returns a double.
return D0->ta(t);

}
void vector_commsampler::dint(double t) {
D0->dint(t);
}
void vector_commsampler::dext(Event x, double t) {
//The input event is in the 'x' variable.
//where:
//     'x.value' is the value (pointer to void)
//     'x.port' is the port number
//     'e' is the time elapsed since last transition
vector vec1=*(vector*)x.value;
int index=vec1.index;
if ((index>-1)&&(index<N)){
	D0->D[index]->dextmessage(x,t);
	D0->heap.update(index);
} else if (index==-1) {
  for (int ind=0;ind<N;ind++){
	D0->D[ind]->dextmessage(x,t);
  	D0->heap.update(ind);
 }
};
}
Event vector_commsampler::lambda(double t) {
//This function returns an Event:
//     Event(%&Value%, %NroPort%)
//where:
//     %&Value% points to the variable which contains the value.
//     %NroPort% is the port number (from 0 to n-1)
y= D0->D[D0->transitionChild]->lambdamessage(t);
vec=*(vector*)y.value;
vec.index=D0->transitionChild;
y.value=&vec;
return y;
}
void vector_commsampler::exit() {
//Code executed at the end of the simulation.
D0->exit();
}

redpajama_set_name: RedPajamaGithub


text:
{% extends "touchtechnology/news/article/detail.html" %}
{% load i18n %}

{% block translations %}

{% trans "Original" %}

            {% language "en" %}
                {{ object.article.headline }}
            {% endlanguage %}

{% endblock %}


text: Descriptions are added in each Folders.


text:
.. Copyright 2018 tsuru authors. All rights reserved.
   Use of this source code is governed by a BSD-style
   license that can be found in the LICENSE file.

++++++++++++++
Event webhooks
++++++++++++++

Event webhooks allow integrating tsuru events with external systems. You can create an event
webhook to notify the occurence of specific event types. When you create an event webhook,
tsuru makes a request to the specified URL for every event according specific filters.

For more info on the client commands for handling webhooks, check
`tsuru client docs <https://tsuru-client.readthedocs.io/en/master/reference.html#event-webhooks>`_.

Configurations
==============

Event webhook configurations basically involve filtering events and configuring the hook request.

Event filtering configurations
------------------------------

By default, all events that the webhook creator has access will trigger it. But the events may be
filtered by some criteria:

- Error only: triggers only failing events
- Success only: triggers only successful events
- Kind type: ``permission`` or ``internal``
- Kind name: one of the values returned by the ``tsuru permission-list`` command, like ``app.create`` or ``pool.update``
- Target type: ``global``, ``app``, ``node``, ``container``, ``pool``, ``service``, ``service-instance``, ``team``, ``user``, ``iaas``, ``role``, ``platform``, ``plan``, ``node-container``, ``install-host``, ``event-block``, ``cluster``, ``volume`` or ``webhook``
- Target value: the value according to the target type. When target type is ``app``, for instance, target value will be the app name

Hook request configurations
---------------------------

- URL: the URL of the request
- Method: ``GET``, ``POST``, ``PUT``, ``PATCH`` or ``DELETE``. Defaults to ``POST``
- Headers: HTTP headers, defined in ``key=value`` format
- Body: Payload of the request, used when the method is ``POST``, ``PUT`` or ``PATCH``. Defaults to the serialized event in JSON
- Proxy: Proxy server used for the requests

The request body may be specified with `Go templates <https://golang.org/pkg/text/template/>`_,
to use event fields as variables. Refer to `event data
<https://github.com/tsuru/tsuru/blob/a631ecea624e94875fb35ab25990ebe51b1ebccb/event/event.go#L190-L211>`_
for the available fields.

Examples
========

Notifying every successful app deploy to a `Slack <https://slack.com/>`_ channel:

.. highlight:: bash

::

    $ tsuru event-webhook-create my-webhook https://hooks.slack.com/services/...
            -d "all successful deploys"
            -t <my-team>
            -m POST
            -H Content-Type=application/x-www-form-urlencoded
            -b 'payload={"text": "[{{.Kind.Name}}]: {{.Target.Type}} {{.Target.Value}}"}'
            --success-only
            --kind-name app.deploy

Calling a specific URL every time a specific app is updated:

.. highlight:: bash

::

    $ tsuru event-webhook-create my-webhook <my-url>
            -t <my-team>
            --kind-name app.update
            --target-value <my-app>


text:
layout: post
title: Reflections on my trip to USA
---

So, two weeks in the USA have passed. Since it was my first visit there I want to share some thoughts on being there. Of course, in comparison to being here.

The first thing that got my attention, that everything is like scaled to be larger. They have larger cars, roads, hotel rooms, enormous shops (should I say "stores"?) and malls. With this there is no feeling of crowd, everyone have enough space.

People seem to be calmer, at the work no one talks loudly, phone ringers are mostly off and if it happens to person to answer a call, he moves far far away from the cubicles.

Weather and nature reminded me of Russia at summer, almost the same as in my birthtown. After 40 c, the 70 f was like a big relief. At Sunday I've been to lake Minnetonka and really enjoyed the place.

I visited Minneapolis. Skyscrapers, restaurants, cars, sky-walks. Nice houses, huge parking lots. Different people everywhere. I've guessed it's like New York, but looks that my guess is not so good.

It was a quick run around the Twin Cities and their surrounding, I liked it. Nice place to visit, and may be nice place to stay for a while.

In couple of words about the job done there - one week as a configuration manager - writing and testing scripts, hunting minor bugs once in a while, and another was more like a run to clean installation - looking for issues with the infrastructure, and fixing them where possible. A lot of stuff learned, it felt like going out of the shell of electronic payments and terminals to database management, active directory integration, user authentication, printing engine. The feeling was that 24 hours a day are not enough to fix all the issues, but the marathon was really worth it.

By the way, I really enjoy flying. The long flight gives you the power to work without distractions from colleagues, internet, phone calls. Concentration is good, and you even don't need to stand up to grab another beer :)

All in one, except being away from home. Almost good.


text:
'''
http://security.stackexchange.com/questions/6740/flaw-in-encryption-through-pseudorandom-number-stream-from-pgp-documentation
'''
import os
import sys
import random
import time
#Adding directory to the path where Python searches for modules
cmd_folder = os.path.dirname('/home/arvind/Documents/Me/My_Projects/Git/Crypto/modules/')
sys.path.insert(0, cmd_folder)
import mtrand

if __name__ == "__main__":
    t1= random.randint(40,1000)
    print "Sleeping for ",t1," seconds"
    time.sleep(t1)

    seed= int(time.time())
    print "Seed:", seed
    mtrand.init_by_array(seed)

    t2= random.randint(40,1000)
    print "Sleeping for ",t2," seconds"
    time.sleep(t2)

    num= mtrand.genrand_int32()
    print "First random number is:", num
    print "Lets now try and predict the seed, using the random number. This is just reversing the process."

    print "Getting current timestamp and finding range"
    cur_timestamp= int(time.time())
    for guess in xrange(cur_timestamp-1024,cur_timestamp):
        mtrand.clear_state()
        mtrand.init_by_array(guess)
        g1= mtrand.genrand_int32()
        if g1==num:
            print '-'*75
            print "Seed found in the reverse process. The seed is", guess
            print '-'*75
            break
        else:
            continue


text:
class Play extends Phaser.State {
    create () {
        // define game objects
        this.paddle_one = null;
        this.paddle_two = null;
        this.ball = null;
        this.emitter = null;
        this.bgGraphics = null;

        // paddles
        this.paddle_one = new Paddle(this.game, 0, this.game.world.centerY, false, false);
        this.paddle_two = new Paddle(this.game, this.game.world.width - 16, this.game.world.centerY, true, true);

        // ball
        this.ball = new Ball(this.game, this.game.world.centerX, this.game.world.centerY, false);
        game.input.onDown.addOnce(this.ball.launch(), this);

        // bg color
        game.stage.backgroundColor = "#292953";

        // particles emitter
        this.particleEmitter();

        // screen text stuff
        this.scoreText();
        this.startText();

        // draw middle dotted line
        this.drawLine();

        game.input.onDown.addOnce(this.removeStarText(), this);
    }

    update () {
        this.game.physics.arcade.collide(this.paddle_one, this.ball);
        this.game.physics.arcade.collide(this.paddle_two, this.ball);

        if (this.ball.body.touching.left) {
            this.emitter.x = this.ball.x;
            this.emitter.y = this.ball.y;
            this.emitter.start(true, 2000, null, 20);
            this.game.camera.shake(0.000005, 200);
        } else if (this.ball.body.touching.right) {
            this.emitter.x = this.ball.x;
            this.emitter.y = this.ball.y;
            this.emitter.start(true, 2000, null, 20);
            this.game.camera.shake(0.000005, 200);
        }

        if (this.ball.body.blocked.right) {
            this.paddle_one.score += 1;
            this.score_one.setText(`Score: ${this.paddle_one.score}`);
            this.game.camera.shake(0.005, 1000);
        } else if (this.ball.body.blocked.left) {
            this.paddle_two.score += 1;
            this.score_two.setText(`Score: ${this.paddle_two.score}`);
            this.game.camera.shake(0.005, 1000);
        }

        if (this.paddle_one.score >= 5) {
            this.game.state.start('win');
        } else if (this.paddle_two.score >= 5) {
            this.game.state.start('lose');
        }
    }

    removeStarText () {
        return function () {
            this.start_text.destroy();
        }
    }

    scoreText () {
        this.score_one = this.game.add.text(
            32, 32,
            `Score: ${this.paddle_one.score}`,
            { font: '20px Courier', fill: '#FFF' }
        );

        this.score_two = this.game.add.text(
            800-132, 32,
            `Score: ${this.paddle_two.score}`,
            { font: '20px Courier', fill: '#FFF' }
        );
    }

    startText() {
        this.start_text = this.game.add.text(
            this.game.world.centerX-160, this.game.world.centerY-22,
            `Click to Start`,
            { font: '40px Courier', fill: '#FFF' }
        );
    }

    drawLine () {
        this.bgGraphics = game.add.graphics(0, 0);
        this.bgGraphics.lineStyle(2, 0xFFFFFF, 1);

        for (var y = 0; y < this.game.world.height; y += 5 * 2) {
            this.bgGraphics.moveTo(this.game.world.centerX, y);
            this.bgGraphics.lineTo(this.game.world.centerX, y + 5);
        }
    }

    particleEmitter () {
        this.emitter = game.add.emitter(0, 0, 100);
        this.emitter.makeParticles('particle');
        this.emitter.gravity = 200;
    }
}


text:
layout: page
title: "GRMN 3010: Advanced German 1 Statistics"
comments: true
description: "blanks"
keywords: "GRMN,3010,CU,Boulder"
---

#### GRADE AND WORKLOAD STATISTICS

**Percent withdrawn**: 2.34%

**Percent incomplete**: 0.14%

**Average grade** (4.0 scale): 3.41

**Standard deviation in grades** (4.0 scale): 0.21

**Average workload** (raw): 2.49

**Standard deviation in workload** (raw): 0.21

#### COURSE AND INSTRUCTOR RATINGS/INFORMATION

**Average course rating** (6 point scale): 4.98

**Standard deviation in course rating** (6 point scale): 0.34

**Average instructor rating** (6 point scale): 5.34

**Standard deviation in instructor rating** (6 point scale): 0.31

**Instructors**: Saskia Barbara Hintz, Petra Landfester, Beverly Marie Weber

#### GENERAL CLASS INFORMATION

**Years provided**: Fall 2006, Spring 2007, Fall 2007, Spring 2008, Fall 2008, Spring 2009, Fall 2009, Spring 2010, Fall 2010, Spring 2011, Fall 2011, Spring 2012, Fall 2012, Spring 2013, Fall 2013, Spring 2014, Fall 2014, Spring 2015, Fall 2015, Spring 2016, Fall 2016, Spring 2017

**Credits**: 3

**RAP/Honors class?** Neither

**Number of Sections**: 24

**Department**: GSLL

**College**: College of Arts and Sciences

**A&S Division**: Arts and Humanities

**Level**: Upper

**Activity**: LEC - Lecture


text:
layout: default
---

{% include note-header.html %}

Two Factor Auth (2FA)

        GREE

Info regarding GREE 2FA.

        GREE supports any software app that supports TOTP tokens.

        It appears there is no information about this service provided
        online though it is readily accessible in the "My Profile"
        section of the management console.

        How to Setup 2FA for GREE

            Go to the Two Factor Auth management page

            At the top of the page, click "Enable" under
            "Two Factor Auth"

            Follow the wizard to configure your Two Factor
            Authentication Provider

            The next time you log in to the GREE website or app it will
            prompt you for your token


text:
. "$WORKSPACE/JenkinsSdkSetupScripts/JenkinsScripts/Pipeline/util.sh" 2> /dev/null
. "$WORKSPACE/JenkinsSdkSetupScripts/JenkinsScripts/Pipeline/sdkUtil.sh" 2> /dev/null

CheckVerticalizedParameters

# USAGE: ResetRepo
ResetRepo (){
    echo === ResetRepo $PWD, $@ ===

    # Assumes the current directory is set to the repo to be reset
    CheckCreds
    git fetch --progress origin
    git checkout master || git checkout -b master || CleanCurrentRepo
    git pull origin master

    # Delete $GitDestBranch, reset it to master, prep for next build and fresh write
    if [ "$GitDestBranch"!="master" ]; then
        git branch -D $GitDestBranch || true
        git checkout -b $GitDestBranch || true
        git checkout $GitDestBranch
    fi
}

# USAGE: DoWork
DoWork () {
    echo == DoWork $PWD, $@ ==

    # These are always shared, never modified directly, and never arc-patched
    # We sync master on the SHARED_WORKSPACE
    SyncGitHubRepo "$SHARED_WORKSPACE" "SDKGenerator" "SDKGenerator"
    SyncGitHubRepo "$SHARED_WORKSPACE/sdks" "$SdkName"
    # We sync $GitSdkGenBranch in the real workspace
    SyncWorkspaceRepo "$SHARED_WORKSPACE" "$WORKSPACE" "SDKGenerator" "SDKGenerator" "$GitSdkGenBranch"
    SyncWorkspaceRepo "$SHARED_WORKSPACE/sdks" "$WORKSPACE/sdks" "$SdkName" "$GitSdkDestBranch"

    if [ ! -z "$SdkGenPrvTmplRepo" ]; then
        SyncGitHubRepo "$WORKSPACE/SDKGenerator/privateTemplates" "$SdkGenPrvTmplRepo" "$SdkGenPrvTmplRepo" "$GitPrvTmplBranch"
    fi

    # DoJcuNugetUpdate

    ForcePushD "$WORKSPACE/sdks/$SdkName"
    ResetRepo
}

echo === Beginning testInit ===
DoWork "$@"


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ApiTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            //todo: implement the console client for api tester
        }
    }
}


text:
layout: compress
---
<!DOCTYPE html>
<html lang="{% if page.language %}{{ page.language | downcase }}{% else %}{{ site.language | downcase }}{% endif %}">
{% include head.html %}

<body class="home-template">
    <div class="site-wrapper">
        {{ content }}
        {% include footer.html %}
    </div>
</body>

{% include global.html %}
</html>


text:
title: Hot plug cpu
category: feature
authors: adahms, roy, sven
wiki_category: Feature
wiki_title: Hot plug cpu
wiki_revision_count: 33
wiki_last_updated: 2015-02-04
---

# Hot plug cpu

## Summary

This feature allows you to hot plug CPUs to a running virtual machine from the oVirt engine user interface and REST API.

## Owner

*   Name: Roy Golan (MyUser)
*   Email: rgolan@redhat.com

## Current status

*   phase 1 (i.e all content in this wiki) - Done
*   phase 2 - [Hot_plug_cpu#Phase_2](/develop/release-management/features/virt/hot-plug-cpu/#phase-2) desgin stage
*   limitations: unplug isn't supported fully due to libvirt's bug [#1017858](https://bugzilla.redhat.com/show_bug.cgi?id=1017858#c11)
*   Last updated: ,

## Detailed Description

Historically, CPU and memory hot add and remove capabilities were thought of as server hardware RAS features. However, the concepts of CPU and memory hot add and remove are both common and necessary for Virtualized environments. Virtual CPUs and virtual memory assigned to a virtual machine (VM) need to be be added or removed from a running guest in order to meet either the workload's demands or to maintain the SLA associated with the workload. It is also desired for the rapid reconfiguration of a guest once a workload has been completed or migrated and an administrator wants to reconfigure the VM without having to re-boot the VM.

## Benefit to oVirt

This feature enables the following powerful use cases:

*   Admins can ensure customer's SLA are being met
*   Spare hardware can be effectively used - it's common to see systems overdimentioned x3 for an average max load
*   System hardware can be dynamic scaled vertically, down or up, in accordance with your needs \*without restarting\* the virtual machine

## Detailed Design

### Client Usage

The term plug/unplug CPUs is simpler from the user POV. The user just needs to set the desired number of sockets he needs. I.e we support a number which is the multiplication of the Cores per sockets and sockets.

All of this means that the user can now simply change the number of sockets of a running VM while its status is UP. This would trigger a call to VDSM to setNumberOfCpus(vmId, num). there is no notion of plug/unplug.

#### UI

See that "Sockets" text input is editable while the VM is UP (its editable only when UP or DOWN statuses)

![](/images/wiki/Hotplug-cpu-gui.png)

#### REST

This is a typical update to a VM resource. The number of sockets is changed to 2. this will hotplug 1 more CPU to the machine.

      hotplug-cpu.xml
`  `<vm><cpu><topology sockets="2" cores="1"></topology></cpu></vm>

        curl -X PUT --user user@domain:pass -H "Content-Type:application/xml" -d@hotplug-cpu.xml  `[`http://localhost:8080/ovirt-engine/api/vms/`](http://localhost:8080/ovirt-engine/api/vms/)`${vmId}

### Engine

Engine must allow updates to the number of sockets field while the VM is up. When calling the UpdateVmCommand, we will check
if the current number is different then the stored number of sockets. if it is we then call VDSM setNumberOfCpus(vmId, num).
If we returned with no error, the new number of CPUs is stored into db. The engine view of the actual vCpus of this machine is now syncronized.

A pre-condition for adding more CPUs is that a VM has a MAX_VCPUS set in its xml. this means we have to start the VM with some configured maximum. this number doesn't affect any reosurce allocation on the VM itself. Till today the MAX_VCPUS was equal to the number of CPUs the VM started with. So its impossible to hot plug more CPUs
to machines that started < 3.4 (i.e setup upgraded and the machines stayed UP)

pseudo-code for building a VM xml we send to VDSM

      if (hot plug is supported for this compat version) {
          smp = ConfigValues.MaxNumOfVmCpus
      }

#### Update Vm Command - Error handling

The API to hot plug CPU is using UpdateVmCommand. essentially if there is a change in topology a child Command HotSetNumberOfCpus will be called. The call to the child command fails atomically and it shall \*NOT\* abort the parent UpdateVmCommand.

e.g - we want to update a running's VM desription and to hotplug 1 more cpu

1.  the updated values are desctiption and numberOfSockets
2.  UpdateVmCommad saves the descitption to DB
3.  HostSetNumberOfCpus is called with new number of sockets but fails
4.  UpdateVmCommand check for the failure and outputs and AuditLog
5.  UpdateVmCommand terminates and commit changes to DB with the new description only. the old number of sockets remains unchanged

## changes

| Component       | requirement                                                                                | completed                                                    |
|-----------------|---------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------|
| Engine          | UpdateVmCommand permits number of cpus change while VM is running                                                   | Done                                                         |
| Engine          | UpdateVmCommand canDo fail if # of cpus is not supported on host (config value?, get the actual number from caps?) | 0                                                            |
| Engine          | UpdateVmCommand send setNumberOfCpus verb when cpus changes                                                         | Done                                                         |
| Engine          | UpdateVmCommand stores the new number of CPUs only if the call to setNumberOfCpus succeeded                         | Done                                                         |
| Engine - osinfo | create configuration for plug/unplug                                                                                | not clear which OSs we block/allow - PPC is blocked entirely |
| Engine          | create informative Audit log when setNumberOfCpus fails                                                             | Done                                                         |
| VDSM            | create new verb 'setNumberOfCpus'. it would be used for both plug/unplug cpus                                       | Done                                                         |
| VDSM            | in vm.py, bind the verb to an underling call to libvirt's setVcpus                                                  | Done                                                         |
| VDSM            | call before/after hooks for plug/unplug to enable various method for onlining the CPU at the guest OS               | Done                                                         |

      === check list ===

| Component | check                                                                                | completed |
|-----------|----------------------------------------------------------------------------------------------------|-----------|
| VDSM      | check migration of a VM that was hotplugged with cpus and re-migrated it (not sure changes needed) |           |

## Dependencies / Related Features

*   ***setNumOfCpus --guest*** (using qemu guest agent for plug/unplug)

There is no direct dependency on QEMU's agent. But for the sake of documenting any detail we have, its worth mentioning that<b>

libvirt's setNumOfCpus --guest will use the guest agent to offline/online the requested cpu instead of a real plug/unplug

i.e that the as for RHEL, the guest alone handles the plug/unplug without the need of the agent to do the underling job.

for more details see comment 11 on Bug [#1017858](https://bugzilla.redhat.com/show_bug.cgi?id=1017858#c11)

[qemu-guest-agent](http://wiki.qemu.org/Features/QAPI/GuestAgent)

## Guest OS Support Matrix

| OS                               | Version                                   | Arch      | Plug            | Unplug          |
|----------------------------------|-------------------------------------------|-----------|-----------------|-----------------|
| Red Hat Enterprise Linux 6.3     |                                           | x86       | <center>
                                                                                +

                                                                                </center>        | <center>
                                                                                -

                                                                                </center>        |
| Red Hat Enterprise Linux 6.5     |                                           | x86       | <center>
                                                                                +

                                                                                </center>        | <center>
                                                                                +

                                                                                </center>        |
| Microsoft Windows Server 2003    | All                                       | x86       | <center>
                                                                                -

                                                                                </center>        | <center>
                                                                                -

                                                                                </center>        |
| Microsoft Windows Server 2003    | All                                       | x64       | <center>
                                                                                -

                                                                                </center>        | <center>
                                                                                -

                                                                                </center>        |
| Microsoft Windows Server 2008    | All x86                                   | <center>
                                                                                -

                                                                                </center>  | <center>
                                                                                -

                                                                                </center>        |
| Microsoft Windows Server 2008    | Standard, Enterprise                      | x64       | Reboot Required | Reboot Required |
| Microsoft Windows Server 2008    | Datacenter                                | x64       | <center>
                                                                                +

                                                                                </center>        | <center>
                                                                                ?

                                                                                </center>        |
| Microsoft Windows Server 2008 R2 | All                                       | x86       | <center>
                                                                                -

                                                                                </center>        | <center>
                                                                                -

                                                                                </center>        |
| Microsoft Windows Server 2008 R2 | Standard, Enterprise                      | x64       | Reboot Required | Reboot Required |
| Microsoft Windows Server 2008 R2 | Datacenter                                | x64       | <center>
                                                                                +

                                                                                </center>        | <center>
                                                                                ?

                                                                                </center>        |
| Microsoft Windows Server 2012    | All                                       | x64       | <center>
                                                                                +

                                                                                </center>        | <center>
                                                                                ?

                                                                                </center>        |
| Microsoft Windows Server 2012 R2 | All                                       | x64       | <center>
                                                                                +

                                                                                </center>        | <center>
                                                                                ?

                                                                                </center>        |
| Microsoft Windows 7              | All                                       | x86       | <center>
                                                                                -

                                                                                </center>        | <center>
                                                                                -

                                                                                </center>        |
| Microsoft Windows 7              | Starter, Home, Home Premium, Professional | x64       | Reboot Required | Reboot Required |
| Microsoft Windows 7              | Enterprise, Ultimate                      | x64       | <center>
                                                                                +

                                                                                </center>        | <center>
                                                                                ?

                                                                                </center>        |
| Microsoft Windows 8.x            | All                                       | x86       | <center>
                                                                                +

                                                                                </center>        | <center>
                                                                                ?

                                                                                </center>        |
| Microsoft Windows 8.x            | All                                       | x64       | <center>
                                                                                +

                                                                                </center>        | <center>
                                                                                ?

                                                                                </center>        |

## Documentation / External references

*   [oVIrt VDSM RFE](https://bugzilla.redhat.com/show_bug.cgi?id=1036492)
*   [QEMU hotplug cpu feature wiki page](http://wiki.qemu.org/Features/CPUHotplug)
*   [Linux Kernel Documentation for hotplug](https://www.kernel.org/doc/Documentation/cpu-hotplug.txt)

## Open Issues

#### Possible error when migrating a VM which its max cpu is lower than what currently in **'' <vcpu current=n>m</vcpu>**''

The current VM on the source has ***n*** cpus attached and need ***m*** maximum to be able to online more.
if ***m1*** is the max cores on the the source ***H1*** host and ***m2*** is the maximum on destination host ***H2***
if ***m1 > m2*** the underlying migration should fail?

#### Possible CPU pinning problems

if we have cpu pinning for cpu 1-4 and we start the VM with 4 CPU and then we offline 2 CPUs and then we online them back - is the pinning kept?

#### hook support

hook support is provided to solve potential problems with online/offline the cpu after the actual addition to the VM system. Its not clear if some linux versions will have the cpu added but offline in the system so the hook is to cover the gap.

      /usr/libexec/vdsm/hooks/before_set_num_of_cpus
      /usr/libexec/vdsm/hooks/after_set_num_of_cpus

## Phase 2

Due to libvirt bug on unplug the engine has an inconsistent view of the amount of CPUs the VM has.
i.e after unplugging 4 vcpus to 2 vcpus the VM entity in DB has 4 and in qemu process it will decrease to 2

**status:** in progress
 **related bugs:** [1077515](https://bugzilla.redhat.com/show_bug.cgi?id=1077515)

### block Unplug

*   block unplug operation (based on static vm cpu count)
*   engine can do
*   UI grey-out lower values
*   vdc_option for unplug=false in 3.4 till otherwise be it supported.
*   add it to engine-config so its exposed to admins

### notify VDSM Guest Agent

*   call vga (vdsm guest agent) setNumCpus(num:int)
*   log if unsupported operation on guest
*   call setnumofCpu will trigger a refresh

### report topology

*   report the CPU topology under VM subtab

      TODO scketch it

*   format of the topology (Vinzenz please fill in)

note: VDSM-guest-agent work for reporting this is already in progress - <http://gerrit.ovirt.org/23268>

## Testing

*   how to check the guest CPUs - LINUX

      lscpu -e -a

TODO - format the tests

1.  CPU hot unplug \\ CPU loaded
    1.  Set up
    2.  Actions
        1.  Have a VM with 2 CPUs with 100 % utilization - try to hot unplug 1 CPU.
        2.  Hot plug 1 CPU.

    3.  Expected Results
        1.  See how the OS handle the requiest in such case.
        2.  As the unplug process should take time, interesting to see, how the OS respose to the hot plug.

    4.  Breakdown

2.  Negative test - Add CPU above max
    1.  Set up
    2.  Actions
        1.  Update VM number of CPUs, to a value greater than host capabilities, while VM is running.

(Check what is the maximum number of CPUs, supported on host by getVdsCaps on host).

1.  1.  Expected Results
        1.  CanDoAction fail

    2.  Breakdown

2.  Negative test - CPU hot plug single CPU
    1.  Set up
    2.  Actions
        1.  For a VM with 1 CPU, try to run CPU hot unplug.

    3.  Expected Results
        1.  Expect CanDoAction, since 1 CPU is the minimum.

    4.  Breakdown

3.  Negative test - CPU hot plug, before qemu-kvm updated
    1.  Set up

Background:

When running CPU hot plug/unlug, the engine gets acked from qemu-kvm side, even before CPU count has actually updated in qemu-kvm. Therefore, user is reflected that the CPU number was already updated. At this point of time, user can run a 2nd CPU plug/hotplug. Actions

1. Add CPUs to a running VM (2->4, for example)

2. Remove CPU (4->2, for example), right after the hot add (step 1).

         To see the number of CPUs is yet increased, see test plan documentation on how to do so on guest.

Expected Results

2. Should fail nicely. Breakdown [338998] Negative test - CPU pinning Set up Actions

1. Have a VM with cpu pinning defined to 3 first CPUs, in ordered manner. Start the VM with 4 CPUs.

2. Hot unplug 2 CPUs. (update number of CPUs from 4 to 2), while VM is running.

3. Have a VM with cpu pinning defined to 2 CPUs, and CPU pinning to #2, & #3. Hot plug 2 CPUS, and then hot unplug 2 CPUs. Expected Results

2. Should fail, cpu pinning should block this change.

3. Should fail. Libvirt should block this upon cpu pinning. Breakdown [337910] Negative test - Hot plug during migration Set up Actions

1. Try to CPU hot-plug (add or reduce CPUs) during VM migration. Expected Results

1. Failure message or can do action (no exceptions in the log). Breakdown [338661] Positive test - CPU hot plug & unplug toggle Set up Actions

1. CPU hot plug & unplug toggle several times. Expected Results

2. CPU number should get updated as configured on guest. Breakdown [337912] Positive test - CPU pinning Set up Actions

1. Have a VM with cpu pinning defined to 3 first CPUs, in ordered manner. Start the VM with 4 CPUs.

2. Hot unplug 1 CPU (update number of CPUs from 4 to 3), while VM is running. Expected Results

1. Should be successful.

2. Should be successful. Breakdown [338718] Positive test - CPU thread Set up Actions

1. CPU hot plug 2->4, without cluster CPU thread activated.

2. Also consider here SLA cluster level hypertherding, and in case it is active, the number of CPUs = Hyperthreding (CPU Thred) \* Cores \* Sockets Expected Results

1. See that the maximum allowed number of CPUs = CPU cores \* CPU sockets.

2. See that maximum allowed number of CPUs = CPU cores \* CPU sockets \* CPU thread Breakdown [337907] Positive test - Hot Add\\Remove CPUs Set up Actions

1. Start A VM with 2 CPUs, 2 cores each .

2. Update number of CPUs to 4, while VM is running.

3. Update number of CPUs to 2, while VM is running.

Expected Results

2. a. See that the number of CPUs updated correctly & successfully in UI and REST.

         b. Verify CPU count = 4, by checking it on guest (see test plan documentaion for how to).
         (it may take some time to reach the correct CPU count.)

3. Same as 2, expect CPU count =2. Breakdown [337909] Positive test - Migrate VM hot plugged with CPUs Set up

Require 2 hosts for migration. Actions

1. CPU hotplug add: While VM is running, add more CPUs, for example, for a VM with 2 CPUs, update to 4 CPUs.

2. Migrate the VM.

3. Migrate VM back to original host.

4. Repeat 1-3 for CPU hot unplug of 4->2.

5. Have 2 VMs, each on a separate host. CPU hot plug on VM 1 from 2->4. CPU hot unplug on VM 2 from 4->2. Migrate concurretly VM1 and VM2. Expected Results

1. CPU hot plug should be successful. Check on guest by running 'lscpu' that the CPU number has been updated to 4.

2. Migration should succeed. Check on guest (see test plan documentaion for how to), that the CPU number = 4 .

3. Same as 2.

4. Expect same results as 1-3

5. After migrations, the CPU number on guest should be as configured. Breakdown [337913] Positive test - vdsm hooks Set up

vdsm hooks - vdsm call before/after hooks for plug/unplug to enable various method for onlining the CPU at the guest OS Actions

1. Fill on host, where VM is running, these vdsm hook files:

a. /usr/libexec/vdsm/hooks/before_set_num_of_cpu, for example, with this content: echo "running before_set_num_of_cpu"

b. /usr/libexec/vdsm/hooks/after_set_num_of_cpu, for example, with this content: echo "running after_set_num_of_cpu"

2. Plug: Add CPUs to a VM, for example, 2->4.

3. Unplug: Reduce CPUs to a VM, for example, 4->2.

Expected Results

2. - Check on guest that CPU number was updated (see test plan documentaion for how to).

             -  Verify that both hook files run & exceuted.

3. Same as 2, Except due to bug 1017858 , the after script will not be called till resolved. Breakdown [339000] System test Set up

Have a VM with a single CPU, which is fully utilized Actions

1. . Hot plug CPU 1 -> 2. Expected Results

1. Check adaptation of the OS of the CPU change: Verify indeed the hot plug indeed improve the performance, and the 2nd CPU is used to balance the load.


text:
require "service/shared_service_tests"
require "net/http"

class ActiveStorage::Service::DiskPublicServiceTest < ActiveSupport::TestCase
  tmp_config = {
    tmp_public: { service: "Disk", root: File.join(Dir.tmpdir, "active_storage_public"), public: true }
  }
  SERVICE = ActiveStorage::Service.configure(:tmp_public, tmp_config)

  include ActiveStorage::Service::SharedServiceTests

  test "public URL generation" do
    url = @service.url(@key, filename: ActiveStorage::Filename.new("avatar.png"))

    assert_match(/^https:\/\/example.com\/rails\/active_storage\/disk\/public\/#{@key}/, url)
  end
end


text:
namespace ITMMessanger.Core
{
    using System;
    using System.Collections.Generic;

    public partial class Connection
    {
        public int ID { get; set; }
        public int UserID { get; set; }
        public string ConnectionID { get; set; }

        public virtual User User { get; set; }
    }
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:javaee="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" id="WebApp_9" version="2.4">
  <display-name>Freemarker Struts2 example - viralpatel.net</display-name>
  <filter>
    <filter-name>struts2</filter-name>
    <filter-class>
          org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
    </filter-class>
  </filter>
  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>


text:
from pyramid.view import view_config
from pyramid.response import Response
import json

@view_config(route_name='index', request_method='GET')
def index(request):
    return Response('MetadataCollector API')

@view_config(route_name='collection_documents', request_method='GET')
def collection_documents(request):
    collection_acronym = request.matchdict['collection_acronym']
    result = {
        'collection_acronym': collection_acronym,
    }
    return Response(json.dumps(result), content_type="application/json")

@view_config(route_name='journal_documents', request_method='GET')
def journal_documents(request):
    journal_issn = request.matchdict['journal_issn']
    result = {
        'journal_issn': journal_issn,
    }
    return Response(json.dumps(result), content_type="application/json")

@view_config(route_name='collection_citations', request_method='GET')
def collection_citations(request):
    collection_acronym = request.matchdict['collection_acronym']
    result = {
        'collection_acronym': collection_acronym,
    }
    return Response(json.dumps(result), content_type="application/json")

@view_config(route_name='journal_citations', request_method='GET')
def journal_citations(request):
    journal_issn = request.matchdict['journal_issn']
    result = {
        'journal_issn': journal_issn,
    }
    return Response(json.dumps(result), content_type="application/json")


text:
//
// $Id: TooUpdateServlet.java 306 2006-03-16 15:40:03Z shane $
//

package edu.gemini.spdb.rapidtoo.www;

import edu.gemini.pot.spdb.IDBDatabaseService;
import edu.gemini.pot.sp.SPObservationID;
import edu.gemini.spdb.rapidtoo.TooUpdate;
import edu.gemini.spdb.rapidtoo.TooUpdateException;
import edu.gemini.spdb.rapidtoo.InactiveProgramException;
import edu.gemini.spdb.rapidtoo.impl.TooUpdateFunctor;
import edu.gemini.util.security.auth.keychain.KeyService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.security.Principal;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * A servlet that receives update requests, creates a {@link TooUpdate} object,
 * and applies it to the indicated program.
 */
public class TooUpdateServlet extends HttpServlet {
    private static final Logger LOG = Logger.getLogger(TooUpdateServlet.class.getName());

    private final KeyService _ks;
    private final IDBDatabaseService _db;
    private final Set<Principal> _user;

    public TooUpdateServlet(IDBDatabaseService db, KeyService ks, Set<Principal> user) {
        this._ks = ks;
        this._db = db;
        this._user = user;
    }

    protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
        _doTooUpdate(req, res);
    }

    protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
        _doTooUpdate(req, res);
    }

    private void _doTooUpdate(HttpServletRequest req, HttpServletResponse res) throws IOException {
        TooUpdate update;
        try {
            update = new HttpTooUpdate(req);
        } catch (BadRequestException ex) {
            res.sendError(HttpServletResponse.SC_BAD_REQUEST, ex.getMessage());
            return;
        }

        String obsIdStr = null;

        int code = 503;
        String error = "Database unavailable.";
        Exception fex = null;

        try {
            TooUpdateFunctor func = TooUpdateFunctor.update(_db, _ks, update, _user);
            SPObservationID obsId = func.getObservationId();
            if (obsId == null) {
                fex = func.getException();
            } else {
                obsIdStr = obsId.toString();
            }
        } catch (InactiveProgramException ex) {
            code = 403;
            error = "Program is not active.";
        } catch (TooUpdateException ex) {
            code = 404;
            error = ex.getMessage();
        }

        if (obsIdStr != null) {
            sendResponse(res, obsIdStr);
        } else if (fex != null) {
            LOG.log(Level.INFO, "Bad request", fex);
            res.sendError(HttpServletResponse.SC_BAD_REQUEST, fex.getMessage());
        } else {
            // Just send the last error we encountered, if any.
            res.sendError(code, error);
        }
    }

    public static void sendResponse(HttpServletResponse res, String data) {

        res.setContentType("text/html");

        BufferedOutputStream bos = null;
        try {
            OutputStream out = res.getOutputStream();
            bos = new BufferedOutputStream(out);
            bos.write(data.getBytes());
        } catch (IOException ex) {
            LOG.log(Level.SEVERE, "Problem sending response", ex);
        } finally {
            try {
                if (bos != null) bos.close();
            } catch (IOException ex) {
                LOG.log(Level.SEVERE, "Problem closing response", ex);
            }
        }
    }
}


text:
Scales the image passed in to be the size of the current image,

```cpp

ofxCvImage first;
first.allocate(640, 480);
ofxCvImage second;
second.allocate(320, 240);

second.scaleIntoMe(first); // first is now 320,240

```


text:
package ensemble.samples.graphics.images;

import ensemble.Sample;
import ensemble.controls.SimplePropertySheet;

import javafx.scene.Node;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.image.PixelWriter;
import javafx.scene.image.WritableImage;
import javafx.scene.paint.Color;
import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.beans.property.SimpleDoubleProperty;

/**
 * A sample that demonstrates the use of Image Operators.
 *
 * @related graphics/images/ImageProperties
 * @see javafx.scene.image.Image
 * @see javafx.scene.image.ImageView
 * @see javafx.scene.image.PixelWriter
 * @see javafx.scene.image.WritableImage
 */
public class ImageOperatorSample extends Sample {

    SimpleDoubleProperty gridSize = new SimpleDoubleProperty(3.0);
    SimpleDoubleProperty hueFactor = new SimpleDoubleProperty(12.0);
    SimpleDoubleProperty hueOffset = new SimpleDoubleProperty(240.0);

    public ImageOperatorSample() {
        final WritableImage img = new WritableImage(300, 300);
        gridSize.addListener(new InvalidationListener() {
            public void invalidated(Observable observable) {
                renderImage(img, gridSize.doubleValue(), hueFactor.doubleValue(), hueOffset.doubleValue());
            }
        });
        hueFactor.addListener(new InvalidationListener() {
            public void invalidated(Observable observable) {
                renderImage(img, gridSize.doubleValue(), hueFactor.doubleValue(), hueOffset.doubleValue());
            }
        });
        hueOffset.addListener(new InvalidationListener() {
            public void invalidated(Observable observable) {
                renderImage(img, gridSize.doubleValue(), hueFactor.doubleValue(), hueOffset.doubleValue());
            }
        });
        renderImage(img, 3.0, 12.0, 240.0);

        ImageView view = new ImageView(img);
        getChildren().add(view);

        // REMOVE ME
        setControls(
                new SimplePropertySheet.PropDesc("Grid Size", gridSize, 0d, 10d),
                new SimplePropertySheet.PropDesc("Hue Factor", hueFactor, 0d, 32d),
                new SimplePropertySheet.PropDesc("Hue Offset", hueOffset, 0d, 360d)
        );
        // END REMOVE ME
    }

    private static void renderImage(WritableImage img, double gridSize, double hueFactor, double hueOffset) {
        PixelWriter pw = img.getPixelWriter();
        double w = img.getWidth();
        double h = img.getHeight();
        double xRatio = 0.0;
        double yRatio = 0.0;
        double hue = 0.0;

        for (int y = 0; y < h; y++) {
            for (int x = 0; x < w; x++) {
                xRatio = x/w;
                yRatio = y/h;
                hue = Math.sin(yRatio*(gridSize*Math.PI))*Math.sin(xRatio*(gridSize*Math.PI))*Math.tan(hueFactor/20.0)*360.0 + hueOffset;
                Color c = Color.hsb(hue, 1.0, 1.0);
                pw.setColor(x, y, c);
            }
        }
    }

    // REMOVE ME
    public static Node createIconContent() {
        final WritableImage img = new WritableImage(80, 80);
        renderImage(img, 3.0, 12.0, 240.0);
        ImageView iv = new ImageView(img);
        iv.setFitWidth(80);
        iv.setFitHeight(80);
        return iv;
    }
    // END REMOVE ME
}


text:
#include <chrono>
#include <thread>
#include <functional>
#include <atomic>

template<typename _T>
class watchdog
{
public:
	watchdog():
		m_timeout(nullptr),
		m_is_running(false)
	{
	}

	~watchdog()
	{
		stop();
	}

	void start(std::function<void(_T)> cb,
		   std::chrono::milliseconds resolution = std::chrono::milliseconds(100))
	{
		stop();
		m_is_running.store(true, std::memory_order_release);
		m_thread = std::thread([this, cb, resolution]() {
			const auto no_deadline = time_point{};
			timeout_data curr;
			while(m_is_running.load(std::memory_order_acquire))
			{
				auto t = m_timeout.exchange(nullptr, std::memory_order_release);
				if(t)
				{
					curr = *t;
					delete t;
				}
				if(curr.deadline != no_deadline && curr.deadline < std::chrono::steady_clock::now())
				{
					cb(curr.payload);
					curr.deadline = no_deadline;
				}
				std::this_thread::sleep_for(resolution);
			}
		});
	}

	void stop()
	{
		if(m_is_running.load(std::memory_order_acquire))
		{
			m_is_running.store(false, std::memory_order_release);
			if(m_thread.joinable())
			{
				m_thread.join();
			}
			delete m_timeout.exchange(nullptr, std::memory_order_release);
		}
	}

	inline void set_timeout(std::chrono::milliseconds timeout, _T payload) noexcept
	{
		delete m_timeout.exchange(new timeout_data{std::chrono::steady_clock::now() + timeout, payload}, std::memory_order_release);
	}

	inline void cancel_timeout() noexcept
	{
		delete m_timeout.exchange(new timeout_data, std::memory_order_release);
	}

private:
	typedef std::chrono::time_point<std::chrono::steady_clock> time_point;
	struct timeout_data
	{
		time_point deadline;
		_T payload;
	};
	std::atomic<timeout_data *> m_timeout;
	std::atomic<bool> m_is_running;
	std::thread m_thread;
};


text:
<?php
/**
 * Forum presenter class.
 *
 * @author    MyBB Group
 * @version   2.0.0
 * @package   mybb/core
 * @license   http://www.mybb.com/licenses/bsd3 BSD-3
 */

namespace MyBB\Core\Presenters;

use McCool\LaravelAutoPresenter\BasePresenter;
use MyBB\Core\Database\Models\ConversationMessage as ConversationMessageModel;

class ConversationMessagePresenter extends BasePresenter
{
    /** @var ConversationMessageModel $wrappedObject */

    /**
     * @param ConversationMessageModel $resource The conversation being wrapped by this presenter.
     */
    public function __construct(ConversationMessageModel $resource)
    {
        parent::__construct($resource);
    }

    /**
     * @return UserPresenter
     */
    public function author()
    {
        if ($this->wrappedObject->author instanceof UserPresenter) {
            return $this->wrappedObject->author;
        }

        return app()->make(\MyBB\Core\Presenters\UserPresenter::class, [$this->wrappedObject->author]);
    }
}


text:
module Azure::CognitiveServices::ImageSearch::V1_0
  module Models
    #
    # Defines values for ErrorCode
    #
    module ErrorCode
      None = "None"
      ServerError = "ServerError"
      InvalidRequest = "InvalidRequest"
      RateLimitExceeded = "RateLimitExceeded"
      InvalidAuthorization = "InvalidAuthorization"
      InsufficientAuthorization = "InsufficientAuthorization"
    end
  end
end