blog 搬出 phpcloud

刚开始 phpcloud 推的时候,由于是zend推出的,想去试用一下,就把blog迁了过去,没想到麻从此开始了。

blog 访问并不大,但是 phpcloud 经常 把我的服务挂起,估计可能是用的人比较大,资源比较吃紧吧,稍占点资源就给挂起,

刚好 bae3.0 推出,比较中意,适用中。

java(android) rsa 实现与 php 服务端通信

rsa 密钥生成 见 http://blog.andsky.com/js-rsa-use-openssl-make-public-pirvate-key/

android 客户端用rsa 公钥加密后经 base64 编码发到 服务端,服务端使用私钥解密

客户端代码

import java.math.BigInteger;
import java.security.KeyFactory;
import java.security.PublicKey;
import java.security.spec.RSAPublicKeySpec;
import javax.crypto.Cipher;
import sun.misc.BASE64Encoder;



public class rsa {


	public static void main(String[] args) throws Exception {

		String modulus = "C34FF1FF9771ED88814C26905297BAEDCEC03B847D8AB5620848FC100AC0564FAD5364E9834E29118E7B5F8B1B9EAB201730C4860E8AF2ED2E028704105A01044501A9EF6DA2968E76273AAE496A0963A2FEA9B6179A86F28ACC61C087FB1AEEA4E1CB0ADBB9B757C303741DE602FD790953C8E2C004A425C7CAF4813F403DCD";
        String publicExponent = "010001";

        rsa key = new rsa();
        PublicKey publicKey = key.getPublicKey(modulus, publicExponent);
        Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");


        //明文
        String tString = "aabbsdfsdf";
        byte[] plainText = tString.getBytes("UTF-8");
        //加密
        cipher.init(Cipher.ENCRYPT_MODE, publicKey);
        byte[] enBytes = cipher.doFinal(plainText);
        System.out.println(new BASE64Encoder().encode( enBytes ));
	}


	 public PublicKey getPublicKey(String modulus,String publicExponent) throws Exception {
         BigInteger m = new BigInteger(modulus, 16);
         BigInteger e = new BigInteger(publicExponent, 16);
         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(m,e);
         KeyFactory keyFactory = KeyFactory.getInstance("RSA");
         PublicKey publicKey = keyFactory.generatePublic(keySpec);
         return publicKey;

   }




}

服务端代码

 function privatekey_decodeing($crypttext, $privatekey)
    {

        $prikeyid = openssl_get_privatekey($privatekey);
        if (openssl_private_decrypt($crypttext, $sourcestr, $prikeyid,OPENSSL_PKCS1_PADDING))
        {
            return $sourcestr;
        }
        return FALSE;
    }

 $i = file_get_contents("private.key");

$base = 'fgvroFPT8GCIPYkGZJ834V0zQsnwbHKsCpFjpdN6TowUuxc6Bxu5PCF7SaZvb+3eCVEsuAjN73IP
QhRclqPiSv0MNPeZaYxNVPCDBkalsW3+/OuwPr7sQ53/rDwr2et0FnKJtkNyaFROMnxI9wRyg2Tx
h4+Fe60ypCvwY+wT8eg=';

	$b = base64_decode($base);
var_dump(privatekey_decodeing($b, $i));

quercus 4.0.38 发布

修正了不少bug 真是越来越完善了,赞一个

quercus: empty() needs to call ArrayAccess->offsetExists() (#5612, rep by G. Krall)
quercus: session_status() not implemented (#5609, rep by G. Krall)
quercus: self doesn’t work inside a namespace (#5608, G. Krall)
quercus: ReflectionParameter->getClass() not implemented (#5607, rep by G. Krall)
quercus: IllegalArgumentException vfs: not found on JBoss (#5606, rep by G. Krall)
quercus: ReflectionFunction does not work for closures (#5605, rep by G. Krall)
quercus: Xml reader is not working (#5603, rep by qumo)
quercus: call_user_func() needs to call __invoke (#5601, rep by G. Krall)
quercus: instanceof Closure returns false for closures (#5600, rep by G. Krall)
quercus: QuercusCompiledScript.eval() needs to return the Value object (#5589, rep by S. Guo)
quercus: ScriptEngineManager.getEngineByName(“php”) returns Quercus with unicode.semantics=off (#5588, rep by S. Guo)

php实现websocket手游架构设想

众所周知 php 的开发效率确实块。但在 socket 这块一直没有什么大的发展,设想用 两种方案用 php 实现 websocket game 开发

方案1 netty+quercus+php

方案2 Swoole + php

两种方案感觉都可行,quercus 近期更新力度很大,已经解决 mysql 乱码问题。 php 转成 java 测试性能确实不错

Swoole 是近期关注比较多的了,php 原生实现,作者更新速度很快,但缺少实际项目案例。

两种方案选择了 quercus ,感觉应该更稳定一些,实践中,期待项目上线测试效果

又拍云第二封故障信

关于又拍云12月5日故障的说明‏

用户发展太快?不里处理速度还是另人满意的。 补偿好像没收到哈。

尊敬的又拍云用户:
 
我们为12月5日一组作图服务器故障导致部分图片上传失败给您带来的困扰深表抱歉,为避免您对此的担忧,我们向您坦诚这次故障的具体问题,让您了解这次意外的原因。
 
因又拍云存储平台的数据量急速上涨,云处理集群的压力也快速放大。为提前缓解数据放大带来的压力,提升作图服务器集群性能,12月5日凌晨,又拍云存储更新部署了一批新的作图服务器,并开启了作图服务的CPU亲缘性绑定支持,将服务绑定到了相应的CPU核心上。这个模式在非超线程环境的服务器中运行良好。但在这批开启了超线程支持的服务器上,随着当天下午请求高峰期的到来,逐渐出现不稳定现象,导致上层proxy超时,在该集群造成雪崩效应;由于我们初期对故障的定位偏差,在进行了系统内核降级、作图服务版本回滚等几项措施之后,未能快速缓解处理该问题,直至最后关闭超线程支持。
 
在新集群出现不稳定时,我们已紧急切换到了备用集群。但由于作图请求的雪崩效应,导致后备集群一直高负载运行,期间调用图片服务集群的图片上传、缩略图处理的不稳定状况持续了一段时间。在新集群关闭超线程支持、并确认状态正常,重新接入系统后,服务逐步恢复。
 
您信任我们,将您的数据放在了又拍云存储,出现这样的问题,我们非常的不安,也非常的抱歉,一次故障意味着给您带去了巨大的损失,这个损失我们不知该如何弥补,所以我们决定向您补偿一周的流量并延长一个月的存储使用期限。同时我们将对后续服务持续优化以保证更高的稳定性,避免类似意外的再次发生。我们再次恳请您的谅解。感谢您一直以来对又拍云的支持!
 
 
杭州纬聚网络有限公司
2013.12.6

给又拍云用户的一封致歉信‏

从去年开始用又拍云,收到的第一封故障信,总的来说,还是不错的,如果能像七牛一样,后付费就更好了

亲爱的又拍云存储用户:

2013年11月26日12时,又拍云监控系统报警,提示一部分新数据未能通过API接口上传。技术人员迅速排查,发现一台用于业务数据存储的MySQL服务器异常退出。技术人员当即启动应急预案,将这部分服务切换到灾备数据库,并进行了数据同步,至13时左右服务恢复正常。

服务恢复后,经过全面复检确认:该问题原因是又拍云的数据量级近期暴增,触发了MySQL Bug #63815 Reorganization May Make a Page Incompressible (http://bugs.mysql.com/bug.php?id=63815),导致MySQL数据分块损坏,无法启动服务。现已对主库的数据进行了恢复和校验,并于27日凌晨已完成数据切换。

我们为未能及时做好此问题的防范,给一部分用户带来了影响,在此表示万分的抱歉。我们已于27日上午开始进行数据库的升级准备工作,并将尽快部署完成。在万分抱歉的同时,我们希望此问题不至于给您带来过多的困扰。云存储的发展始终伴随着承载更高数据的挑战,在这一挑战过程中必定伴随着一些没有经历大数据存储就很难知悉的问题。恳请大家相信,又拍云团队在8年的发展和磨练中,具备了对未知情况最大可能的预见能力和在最短时间内解决问题的能力。这次问题对于我们是一个深刻的教训,又拍云将着手进行持续的大数据的模拟,确保在更大数据量来临前,我们为大家做好了最安全的防范措施。

同时,也请这个故障时间段内未出现上传故障、未受到影响的各位用户放心,所有用户的数据外部访问和老数据的存储都未受影响,您的服务在此期间确保正常。如对上述情况有疑问,请您立即联系我们进行沟通,我们将竭尽全力协助您获得满意的结果。

最后,再一次向受此故障影响的各位支持又拍云的朋友们表示万分的歉意。

cocos2d-x jsb 绑定 ClippingNode

JSClass  *jsb_ClippingNode_class;
JSObject *jsb_ClippingNode_prototype;

JSBool js_cocos2dx_ClippingNode_isInverted(JSContext *cx, uint32_t argc, jsval *vp)
{
	JSObject *obj = JS_THIS_OBJECT(cx, vp);
	js_proxy_t *proxy = jsb_get_js_proxy(obj);
	cocos2d::CCClippingNode* cobj = (cocos2d::CCClippingNode *)(proxy ? proxy->ptr : NULL);
	JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
	if (argc == 0) {
		bool ret = cobj->isInverted();
		jsval jsret;
		jsret = BOOLEAN_TO_JSVAL(ret);
		JS_SET_RVAL(cx, vp, jsret);
		return JS_TRUE;
	}
    
	JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
	return JS_FALSE;
}
JSBool js_cocos2dx_ClippingNode_visit(JSContext *cx, uint32_t argc, jsval *vp)
{
	JSObject *obj = JS_THIS_OBJECT(cx, vp);
	js_proxy_t *proxy = jsb_get_js_proxy(obj);
	cocos2d::CCClippingNode* cobj = (cocos2d::CCClippingNode *)(proxy ? proxy->ptr : NULL);
	JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
	if (argc == 0) {
		cobj->visit();
		JS_SET_RVAL(cx, vp, JSVAL_VOID);
		return JS_TRUE;
	}
    
	JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
	return JS_FALSE;
}
JSBool js_cocos2dx_ClippingNode_setInverted(JSContext *cx, uint32_t argc, jsval *vp)
{
	jsval *argv = JS_ARGV(cx, vp);
	JSBool ok = JS_TRUE;
	JSObject *obj = JS_THIS_OBJECT(cx, vp);
	js_proxy_t *proxy = jsb_get_js_proxy(obj);
	cocos2d::CCClippingNode* cobj = (cocos2d::CCClippingNode *)(proxy ? proxy->ptr : NULL);
	JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
	if (argc == 1) {
		JSBool arg0;
		ok &= JS_ValueToBoolean(cx, argv[0], &arg0);
		JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
		cobj->setInverted(arg0);
		JS_SET_RVAL(cx, vp, JSVAL_VOID);
		return JS_TRUE;
	}
    
	JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
	return JS_FALSE;
}
JSBool js_cocos2dx_ClippingNode_setStencil(JSContext *cx, uint32_t argc, jsval *vp)
{
	jsval *argv = JS_ARGV(cx, vp);
	JSBool ok = JS_TRUE;
	JSObject *obj = JS_THIS_OBJECT(cx, vp);
	js_proxy_t *proxy = jsb_get_js_proxy(obj);
	cocos2d::CCClippingNode* cobj = (cocos2d::CCClippingNode *)(proxy ? proxy->ptr : NULL);
	JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
	if (argc == 1) {
		cocos2d::CCNode* arg0;
		do {
			if (!argv[0].isObject()) { ok = JS_FALSE; break; }
			js_proxy_t *proxy;
			JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]);
			proxy = jsb_get_js_proxy(tmpObj);
			arg0 = (cocos2d::CCNode*)(proxy ? proxy->ptr : NULL);
			JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object");
		} while (0);
		JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
		cobj->setStencil(arg0);
		JS_SET_RVAL(cx, vp, JSVAL_VOID);
		return JS_TRUE;
	}
    
	JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
	return JS_FALSE;
}
JSBool js_cocos2dx_ClippingNode_getAlphaThreshold(JSContext *cx, uint32_t argc, jsval *vp)
{
	JSObject *obj = JS_THIS_OBJECT(cx, vp);
	js_proxy_t *proxy = jsb_get_js_proxy(obj);
	cocos2d::CCClippingNode* cobj = (cocos2d::CCClippingNode *)(proxy ? proxy->ptr : NULL);
	JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
	if (argc == 0) {
		float ret = cobj->getAlphaThreshold();
		jsval jsret;
		jsret = DOUBLE_TO_JSVAL(ret);
		JS_SET_RVAL(cx, vp, jsret);
		return JS_TRUE;
	}
    
	JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
	return JS_FALSE;
}
JSBool js_cocos2dx_ClippingNode_init(JSContext *cx, uint32_t argc, jsval *vp)
{
	jsval *argv = JS_ARGV(cx, vp);
	JSBool ok = JS_TRUE;
    
	JSObject *obj = NULL;
	cocos2d::CCClippingNode* cobj = NULL;
	obj = JS_THIS_OBJECT(cx, vp);
	js_proxy_t *proxy = jsb_get_js_proxy(obj);
	cobj = (cocos2d::CCClippingNode *)(proxy ? proxy->ptr : NULL);
	JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
	do {
		if (argc == 1) {
			cocos2d::CCNode* arg0;
			do {
				if (!argv[0].isObject()) { ok = JS_FALSE; break; }
				js_proxy_t *proxy;
				JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]);
				proxy = jsb_get_js_proxy(tmpObj);
				arg0 = (cocos2d::CCNode*)(proxy ? proxy->ptr : NULL);
				JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object");
			} while (0);
			if (!ok) { ok = JS_TRUE; break; }
			bool ret = cobj->init(arg0);
			jsval jsret;
			jsret = BOOLEAN_TO_JSVAL(ret);
			JS_SET_RVAL(cx, vp, jsret);
			return JS_TRUE;
		}
	} while(0);
    
	do {
		if (argc == 0) {
			bool ret = cobj->init();
			jsval jsret;
			jsret = BOOLEAN_TO_JSVAL(ret);
			JS_SET_RVAL(cx, vp, jsret);
			return JS_TRUE;
		}
	} while(0);
    
	JS_ReportError(cx, "wrong number of arguments");
	return JS_FALSE;
}
JSBool js_cocos2dx_ClippingNode_getStencil(JSContext *cx, uint32_t argc, jsval *vp)
{
	JSObject *obj = JS_THIS_OBJECT(cx, vp);
	js_proxy_t *proxy = jsb_get_js_proxy(obj);
	cocos2d::CCClippingNode* cobj = (cocos2d::CCClippingNode *)(proxy ? proxy->ptr : NULL);
	JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
	if (argc == 0) {
		cocos2d::CCNode* ret = cobj->getStencil();
		jsval jsret;
		do {
			if (ret) {
				js_proxy_t *proxy = js_get_or_create_proxy(cx, ret);
				jsret = OBJECT_TO_JSVAL(proxy->obj);
			} else {
				jsret = JSVAL_NULL;
			}
		} while (0);
		JS_SET_RVAL(cx, vp, jsret);
		return JS_TRUE;
	}
    
	JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
	return JS_FALSE;
}
JSBool js_cocos2dx_ClippingNode_setAlphaThreshold(JSContext *cx, uint32_t argc, jsval *vp)
{
	jsval *argv = JS_ARGV(cx, vp);
	JSBool ok = JS_TRUE;
	JSObject *obj = JS_THIS_OBJECT(cx, vp);
	js_proxy_t *proxy = jsb_get_js_proxy(obj);
	cocos2d::CCClippingNode* cobj = (cocos2d::CCClippingNode *)(proxy ? proxy->ptr : NULL);
	JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
	if (argc == 1) {
		double arg0;
		ok &= JS_ValueToNumber(cx, argv[0], &arg0);
		JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
		cobj->setAlphaThreshold(arg0);
		JS_SET_RVAL(cx, vp, JSVAL_VOID);
		return JS_TRUE;
	}
    
	JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
	return JS_FALSE;
}
JSBool js_cocos2dx_ClippingNode_create(JSContext *cx, uint32_t argc, jsval *vp)
{
	jsval *argv = JS_ARGV(cx, vp);
	JSBool ok = JS_TRUE;
	
	do {
		if (argc == 1) {
			cocos2d::CCNode* arg0;
			do {
				if (!argv[0].isObject()) { ok = JS_FALSE; break; }
				js_proxy_t *proxy;
				JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]);
				proxy = jsb_get_js_proxy(tmpObj);
				arg0 = (cocos2d::CCNode*)(proxy ? proxy->ptr : NULL);
				JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object");
			} while (0);
			if (!ok) { ok = JS_TRUE; break; }
			cocos2d::CCClippingNode* ret = cocos2d::CCClippingNode::create(arg0);
			jsval jsret;
			do {
				if (ret) {
					js_proxy_t *proxy = js_get_or_create_proxy(cx, ret);
					jsret = OBJECT_TO_JSVAL(proxy->obj);
				} else {
					jsret = JSVAL_NULL;
				}
			} while (0);
			JS_SET_RVAL(cx, vp, jsret);
			return JS_TRUE;
		}
	} while (0);
	
	do {
		if (argc == 0) {
			cocos2d::CCClippingNode* ret = cocos2d::CCClippingNode::create();
			jsval jsret;
			do {
				if (ret) {
					js_proxy_t *proxy = js_get_or_create_proxy(cx, ret);
					jsret = OBJECT_TO_JSVAL(proxy->obj);
				} else {
					jsret = JSVAL_NULL;
				}
			} while (0);
			JS_SET_RVAL(cx, vp, jsret);
			return JS_TRUE;
		}
	} while (0);
	JS_ReportError(cx, "wrong number of arguments");
	return JS_FALSE;
}


extern JSObject *jsb_CCNode_prototype;

void js_cocos2dx_ClippingNode_finalize(JSFreeOp *fop, JSObject *obj) {
    CCLOGINFO("jsbindings: finalizing JS object %p (ClippingNode)", obj);
}

void js_register_cocos2dx_ClippingNode(JSContext *cx, JSObject *global) {
	jsb_ClippingNode_class = (JSClass *)calloc(1, sizeof(JSClass));
	jsb_ClippingNode_class->name = "ClippingNode";
	jsb_ClippingNode_class->addProperty = JS_PropertyStub;
	jsb_ClippingNode_class->delProperty = JS_PropertyStub;
	jsb_ClippingNode_class->getProperty = JS_PropertyStub;
	jsb_ClippingNode_class->setProperty = JS_StrictPropertyStub;
	jsb_ClippingNode_class->enumerate = JS_EnumerateStub;
	jsb_ClippingNode_class->resolve = JS_ResolveStub;
	jsb_ClippingNode_class->convert = JS_ConvertStub;
	jsb_ClippingNode_class->finalize = js_cocos2dx_ClippingNode_finalize;
	jsb_ClippingNode_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
    
	static JSPropertySpec properties[] = {
		{0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER}
	};
    
	static JSFunctionSpec funcs[] = {
		JS_FN("isInverted", js_cocos2dx_ClippingNode_isInverted, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("visit", js_cocos2dx_ClippingNode_visit, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("setInverted", js_cocos2dx_ClippingNode_setInverted, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("setStencil", js_cocos2dx_ClippingNode_setStencil, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("getAlphaThreshold", js_cocos2dx_ClippingNode_getAlphaThreshold, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("init", js_cocos2dx_ClippingNode_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("getStencil", js_cocos2dx_ClippingNode_getStencil, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FN("setAlphaThreshold", js_cocos2dx_ClippingNode_setAlphaThreshold, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
        JS_FS_END
	};
    
	static JSFunctionSpec st_funcs[] = {
		JS_FN("create", js_cocos2dx_ClippingNode_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
		JS_FS_END
	};
    
	jsb_ClippingNode_prototype = JS_InitClass(
                                              cx, global,
                                              jsb_CCNode_prototype,
                                              jsb_ClippingNode_class,
                                              empty_constructor, 0,
                                              properties,
                                              funcs,
                                              NULL, // no static properties
                                              st_funcs);
	// make the class enumerable in the registered namespace
	JSBool found;
	JS_SetPropertyAttributes(cx, global, "ClippingNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
    
	// add the proto and JSClass to the type->js info hash table
	TypeTest t;
	js_type_class_t *p;
	uint32_t typeId = t.s_id();
	HASH_FIND_INT(_js_global_type_ht, &typeId, p);
	if (!p) {
		p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
		p->type = typeId;
		p->jsclass = jsb_ClippingNode_class;
		p->proto = jsb_ClippingNode_prototype;
		p->parentProto = jsb_CCNode_prototype;
		HASH_ADD_INT(_js_global_type_ht, type, p);
	}
}

cocos2d-x 3.0 已经帮定,本代码在 cocos2d-x 2.1.5 下测试通过