/**
* Generate Storm tuple values by Message and Scheme.
* @param msg RocketMQ Message
* @param scheme Scheme for deserializing
* @return tuple values
*/
public static List
并添加一个接口MessageScheme:
package org.apache.storm.rocketmq.spout.scheme;
import java.util.List;
import org.apache.rocketmq.common.message.Message;
import org.apache.storm.spout.Scheme;
public interface MessageScheme extends Scheme {
List deserializeValue(Message msg);
}
和一个实现类 DefaultMessageScheme:
package org.apache.storm.rocketmq.spout.scheme;
import java.nio.ByteBuffer;
import java.util.List;
import org.apache.rocketmq.common.message.Message;
import org.apache.storm.tuple.Fields;
import org.apache.storm.tuple.Values;
public class DefaultMessageScheme extends StringScheme implements MessageScheme {
public static final String FIELD_TAGS = "Tags";
public static final String FIELD_TEYS = "Keys";
public static final String FIELD_BODY = "Body";
public static final Fields DEFAULT_FIELDS = new Fields("Tags", "Keys", "Body");
@Override
public List deserializeValue(Message msg) {
ByteBuffer body = ByteBuffer.wrap(msg.getBody());
String bodyStr = deserializeString(body);
return new Values(msg.getTags(), msg.getKeys(), bodyStr);
}
@Override
public Fields getOutputFields() {
return DEFAULT_FIELDS;
}
}
public class Power {
/**
*Q71-数值的整数次方
*实现函数double Power(double base, int exponent),求base的exponent次方。不需要考虑溢出。
*/
private static boolean InvalidInput=false;
public static void main(
实现两个WEB之间通过session 共享数据
查看tomcat 关于 HTTP Connector 中有个emptySessionPath 其解释如下:
If set to true, all paths for session cookies will be set to /. This can be useful for portlet specification impleme
Parses a raw HTTP request using yii\helpers\Json::decode()
To enable parsing for JSON requests you can configure yii\web\Request::$parsers using this class:
'request' =&g
Sort a linked list in O(n log n) time using constant space complexity.
====analysis=======
mergeSort for singly-linked list
====code======= /**
* Definition for sin
我使用的是ubuntu13.04系统,在安装nginx的时候遇到如下几个问题,然后找思路解决的,nginx 的下载与安装
wget http://nginx.org/download/nginx-1.0.11.tar.gz
tar zxvf nginx-1.0.11.tar.gz
./configure
make
make install
安装的时候出现
在系统开发过程中,总少不免要自己处理一些异常信息,然后将异常信息变成友好的提示返回到客户端的这样一个过程,之前都是new一个自定义的异常,当然这个所谓的自定义异常也是继承RuntimeException的,但这样往往会造成异常信息说明不一致的情况,所以就想到了用枚举来解决的办法。
1,先创建一个接口,里面有两个方法,一个是getCode, 一个是getMessage
public