当前位置: 首页>>代码示例>>Java>>正文


Java UtilAll类代码示例

本文整理汇总了Java中com.alibaba.rocketmq.common.UtilAll的典型用法代码示例。如果您正苦于以下问题:Java UtilAll类的具体用法?Java UtilAll怎么用?Java UtilAll使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UtilAll类属于com.alibaba.rocketmq.common包,在下文中一共展示了UtilAll类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkTopic

import com.alibaba.rocketmq.common.UtilAll; //导入依赖的package包/类
/**
 * Validate topic
 *
 * @param topic
 * @throws com.alibaba.rocketmq.client.exception.MQClientException
 */
public static void checkTopic(String topic) throws MQClientException {
    if (UtilAll.isBlank(topic)) {
        throw new MQClientException("the specified topic is blank", null);
    }

    if (!regularExpressionMatcher(topic, PATTERN)) {
        throw new MQClientException(String.format(
                "the specified topic[%s] contains illegal characters, allowing only %s", topic,
                VALID_PATTERN_STR), null);
    }

    if (topic.length() > CHARACTER_MAX_LENGTH) {
        throw new MQClientException("the specified topic is longer than topic max length 255.", null);
    }

    //whether the same with system reserved keyword
    if (topic.equals(MixAll.DEFAULT_TOPIC)) {
        throw new MQClientException(
                String.format("the topic[%s] is conflict with default topic.", topic), null);
    }
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:28,代码来源:Validators.java

示例2: tryToCompressMessage

import com.alibaba.rocketmq.common.UtilAll; //导入依赖的package包/类
private boolean tryToCompressMessage(final Message msg) {
    byte[] body = msg.getBody();
    if (body != null) {
        if (body.length >= this.defaultMQProducer.getCompressMsgBodyOverHowmuch()) {
            try {
                byte[] data = UtilAll.compress(body, zipCompressLevel);
                if (data != null) {
                    msg.setBody(data);
                    return true;
                }
            }
            catch (IOException e) {
                log.error("tryToCompressMessage exception", e);
                log.warn(msg.toString());
            }
        }
    }

    return false;
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:21,代码来源:DefaultMQProducerImpl.java

示例3: getConsumerRunningInfo

import com.alibaba.rocketmq.common.UtilAll; //导入依赖的package包/类
private RemotingCommand getConsumerRunningInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final GetConsumerRunningInfoRequestHeader requestHeader =
            (GetConsumerRunningInfoRequestHeader) request.decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class);

    ConsumerRunningInfo consumerRunningInfo = this.mqClientFactory.consumerRunningInfo(requestHeader.getConsumerGroup());
    if (null != consumerRunningInfo) {
        if (requestHeader.isJstackEnable()) {
            Map<Thread, StackTraceElement[]> map = Thread.getAllStackTraces();
            consumerRunningInfo.setStackTraceElementMap(map);
            String jstack = UtilAll.jstack(map);
            consumerRunningInfo.setJstack(jstack);
        }

        response.setCode(ResponseCode.SUCCESS);
        response.setBody(consumerRunningInfo.encode());
    }
    else {
        response.setCode(ResponseCode.SYSTEM_ERROR);
        response.setRemark(String.format("The Consumer Group <%s> not exist in this consumer", requestHeader.getConsumerGroup()));
    }

    return response;
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:25,代码来源:ClientRemotingProcessor.java

示例4: StoreCheckpoint

import com.alibaba.rocketmq.common.UtilAll; //导入依赖的package包/类
public StoreCheckpoint(final String scpPath) throws IOException {
    File file = new File(scpPath);
    MapedFile.ensureDirOK(file.getParent());
    boolean fileExists = file.exists();

    this.randomAccessFile = new RandomAccessFile(file, "rw");
    this.fileChannel = this.randomAccessFile.getChannel();
    this.mappedByteBuffer = fileChannel.map(MapMode.READ_WRITE, 0, MapedFile.OS_PAGE_SIZE);

    if (fileExists) {
        log.info("store checkpoint file exists, " + scpPath);
        this.physicMsgTimestamp = this.mappedByteBuffer.getLong(0);
        this.logicsMsgTimestamp = this.mappedByteBuffer.getLong(8);
        this.indexMsgTimestamp = this.mappedByteBuffer.getLong(16);

        log.info("store checkpoint file physicMsgTimestamp " + this.physicMsgTimestamp + ", "
                + UtilAll.timeMillisToHumanString(this.physicMsgTimestamp));
        log.info("store checkpoint file logicsMsgTimestamp " + this.logicsMsgTimestamp + ", "
                + UtilAll.timeMillisToHumanString(this.logicsMsgTimestamp));
        log.info("store checkpoint file indexMsgTimestamp " + this.indexMsgTimestamp + ", "
                + UtilAll.timeMillisToHumanString(this.indexMsgTimestamp));
    }
    else {
        log.info("store checkpoint file not exists, " + scpPath);
    }
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:27,代码来源:StoreCheckpoint.java

示例5: tryToCompressMessage

import com.alibaba.rocketmq.common.UtilAll; //导入依赖的package包/类
/**
 * 尝试压缩消息
 * 如果消息内容超过了规定的大小(默认4KB),就会进行压缩
 *
 * @param msg
 * @return
 */
private boolean tryToCompressMessage(final Message msg) {
    byte[] body = msg.getBody();
    if (body != null) {
        if (body.length >= this.defaultMQProducer.getCompressMsgBodyOverHowmuch()) {
            try {
                byte[] data = UtilAll.compress(body, zipCompressLevel);
                if (data != null) {
                    msg.setBody(data);
                    return true;
                }
            } catch (IOException e) {
                log.error("tryToCompressMessage exception", e);
                log.warn(msg.toString());
            }
        }
    }

    return false;
}
 
开发者ID:medusar,项目名称:rocketmq-commet,代码行数:27,代码来源:DefaultMQProducerImpl.java

示例6: testStackTrace

import com.alibaba.rocketmq.common.UtilAll; //导入依赖的package包/类
@Test
public void testStackTrace() {
    Map<Thread, StackTraceElement[]> map = Thread.getAllStackTraces();

    Set<Map.Entry<Thread, StackTraceElement[]>> entries = map.entrySet();

    for (Map.Entry<Thread, StackTraceElement[]> entry : entries) {
        System.out.println();
        System.out.println("-----------------------Thread:" + entry.getKey().toString() + "------------------------------");
        StackTraceElement[] value = entry.getValue();
        for (int i = 0; i < value.length; i++) {
            StackTraceElement stackTraceElement = value[i];
            System.out.println(stackTraceElement.toString());
        }
    }


    System.out.println(UtilAll.jstack(map));

}
 
开发者ID:medusar,项目名称:rocketmq-commet,代码行数:21,代码来源:LocalTest.java

示例7: decodeMessageId

import com.alibaba.rocketmq.common.UtilAll; //导入依赖的package包/类
public static MessageId decodeMessageId(final String msgId) throws UnknownHostException {
    SocketAddress address;
    long offset;

    byte[] ip = UtilAll.string2bytes(msgId.substring(0, 8));
    byte[] port = UtilAll.string2bytes(msgId.substring(8, 16));
    ByteBuffer bb = ByteBuffer.wrap(port);
    int portInt = bb.getInt(0);
    address = new InetSocketAddress(InetAddress.getByAddress(ip), portInt);

    // offset
    byte[] data = UtilAll.string2bytes(msgId.substring(16, 32));
    bb = ByteBuffer.wrap(data);
    offset = bb.getLong(0);

    return new MessageId(address, offset);
}
 
开发者ID:medusar,项目名称:rocketmq-commet,代码行数:18,代码来源:MessageDecoder.java

示例8: checkTopic

import com.alibaba.rocketmq.common.UtilAll; //导入依赖的package包/类
/**
 * topic 有效性检查
 * 
 * @param topic
 * @throws com.alibaba.rocketmq.client.exception.MQClientException
 */
public static void checkTopic(String topic) throws MQClientException {
    if (UtilAll.isBlank(topic)) {
        throw new MQClientException("the specified topic is blank", null);
    }
    if (!regularExpressionMatcher(topic, PATTERN)) {
        throw new MQClientException(String.format(
            "the specified topic[%s] contains illegal characters, allowing only %s", topic,
            VALID_PATTERN_STR), null);
    }
    if (topic.length() > CHARACTER_MAX_LENGTH) {
        throw new MQClientException("the specified topic is longer than topic max length 255.", null);
    }

    // Topic名字是否与保留字段冲突
    if (topic.equals(MixAll.DEFAULT_TOPIC)) {
        throw new MQClientException(
            String.format("the topic[%s] is conflict with default topic.", topic), null);
    }
}
 
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:26,代码来源:Validators.java

示例9: updateConsumerOffsetOneway

import com.alibaba.rocketmq.common.UtilAll; //导入依赖的package包/类
/**
 * 更新Consumer消费进度
 * 
 * @throws InterruptedException
 * @throws RemotingSendRequestException
 * @throws RemotingTimeoutException
 * @throws RemotingTooMuchRequestException
 * 
 * @throws RemotingConnectException
 */
public void updateConsumerOffsetOneway(//
        final String addr,//
        final UpdateConsumerOffsetRequestHeader requestHeader,//
        final long timeoutMillis//
) throws RemotingConnectException, RemotingTooMuchRequestException, RemotingTimeoutException,
        RemotingSendRequestException, InterruptedException {
    // 添加虚拟运行环境相关的projectGroupPrefix
    if (!UtilAll.isBlank(projectGroupPrefix)) {
        requestHeader.setConsumerGroup(VirtualEnvUtil.buildWithProjectGroup(
            requestHeader.getConsumerGroup(), projectGroupPrefix));
        requestHeader.setTopic(VirtualEnvUtil.buildWithProjectGroup(requestHeader.getTopic(),
            projectGroupPrefix));
    }

    RemotingCommand request =
            RemotingCommand.createRequestCommand(RequestCode.UPDATE_CONSUMER_OFFSET, requestHeader);

    this.remotingClient.invokeOneway(addr, request, timeoutMillis);
}
 
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:30,代码来源:MQClientAPIImpl.java

示例10: endTransactionOneway

import com.alibaba.rocketmq.common.UtilAll; //导入依赖的package包/类
/**
 * 提交或者回滚事务
 */
public void endTransactionOneway(//
        final String addr,//
        final EndTransactionRequestHeader requestHeader,//
        final String remark,//
        final long timeoutMillis//
) throws RemotingException, MQBrokerException, InterruptedException {
    // 添加虚拟运行环境相关的projectGroupPrefix
    if (!UtilAll.isBlank(projectGroupPrefix)) {
        requestHeader.setProducerGroup(VirtualEnvUtil.buildWithProjectGroup(
            requestHeader.getProducerGroup(), projectGroupPrefix));
    }

    RemotingCommand request =
            RemotingCommand.createRequestCommand(RequestCode.END_TRANSACTION, requestHeader);

    request.setRemark(remark);
    this.remotingClient.invokeOneway(addr, request, timeoutMillis);
}
 
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:22,代码来源:MQClientAPIImpl.java

示例11: queryMessage

import com.alibaba.rocketmq.common.UtilAll; //导入依赖的package包/类
/**
 * 查询消息
 */
public void queryMessage(//
        final String addr,//
        final QueryMessageRequestHeader requestHeader,//
        final long timeoutMillis,//
        final InvokeCallback invokeCallback//
) throws RemotingException, MQBrokerException, InterruptedException {
    // 添加虚拟运行环境相关的projectGroupPrefix
    if (!UtilAll.isBlank(projectGroupPrefix)) {
        requestHeader.setTopic(VirtualEnvUtil.buildWithProjectGroup(requestHeader.getTopic(),
            projectGroupPrefix));
    }

    RemotingCommand request =
            RemotingCommand.createRequestCommand(RequestCode.QUERY_MESSAGE, requestHeader);

    this.remotingClient.invokeAsync(addr, request, timeoutMillis, invokeCallback);
}
 
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:21,代码来源:MQClientAPIImpl.java

示例12: decodeMessageId

import com.alibaba.rocketmq.common.UtilAll; //导入依赖的package包/类
public static MessageId decodeMessageId(final String msgId) throws UnknownHostException {
    SocketAddress address;
    long offset;

    // 地址
    byte[] ip = UtilAll.string2bytes(msgId.substring(0, 8));
    byte[] port = UtilAll.string2bytes(msgId.substring(8, 16));
    ByteBuffer bb = ByteBuffer.wrap(port);
    int portInt = bb.getInt(0);
    address = new InetSocketAddress(InetAddress.getByAddress(ip), portInt);

    // offset
    byte[] data = UtilAll.string2bytes(msgId.substring(16, 32));
    bb = ByteBuffer.wrap(data);
    offset = bb.getLong(0);

    return new MessageId(address, offset);
}
 
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:19,代码来源:MessageDecoder.java

示例13: checkTopic

import com.alibaba.rocketmq.common.UtilAll; //导入依赖的package包/类
/**
 * topic 有效性检查
 * 
 * @param topic
 * @throws com.alibaba.rocketmq.client.exception.MQClientException
 */
public static void checkTopic(String topic) throws MQClientException {
    if (UtilAll.isBlank(topic)) {
        throw new MQClientException("the specified topic is blank", null);
    }
    if (!regularExpressionMatcher(topic, validPatternStr)) {
        throw new MQClientException(String.format(
            "the specified topic[%s] contains illegal characters, allowing only %s", topic,
            validPatternStr), null);
    }
    if (topic.length() > CHARACTER_MAX_LENGTH) {
        throw new MQClientException("the specified topic is longer than topic max length 255.", null);
    }

    // Topic名字是否与保留字段冲突
    if (topic.equals(MixAll.DEFAULT_TOPIC)) {
        throw new MQClientException(
            String.format("the topic[%s] is conflict with default topic.", topic), null);
    }
}
 
开发者ID:brucechan0921,项目名称:RocketMQ-3.0.8,代码行数:26,代码来源:Validators.java

示例14: updateConsumerOffsetOneway

import com.alibaba.rocketmq.common.UtilAll; //导入依赖的package包/类
/**
 * 更新Consumer消费进度
 * 
 * @throws InterruptedException
 * @throws RemotingSendRequestException
 * @throws RemotingTimeoutException
 * @throws RemotingTooMuchRequestException
 * 
 * @throws RemotingConnectException
 */
public void updateConsumerOffsetOneway(//
        final String addr,//
        final UpdateConsumerOffsetRequestHeader requestHeader,//
        final long timeoutMillis//
) throws RemotingConnectException, RemotingTooMuchRequestException, RemotingTimeoutException,
        RemotingSendRequestException, InterruptedException {
    // 添加虚拟运行环境相关的projectGroupPrefix
    if (!UtilAll.isBlank(projectGroupPrefix)) {
        requestHeader.setConsumerGroup(VirtualEnvUtil.buildWithProjectGroup(
            requestHeader.getConsumerGroup(), projectGroupPrefix));
        requestHeader.setTopic(VirtualEnvUtil.buildWithProjectGroup(requestHeader.getTopic(),
            projectGroupPrefix));
    }

    RemotingCommand request =
            RemotingCommand.createRequestCommand(MQRequestCode.UPDATE_CONSUMER_OFFSET_VALUE,
                requestHeader);
    this.remotingClient.invokeOneway(addr, request, timeoutMillis);
}
 
开发者ID:brucechan0921,项目名称:RocketMQ-3.0.8,代码行数:30,代码来源:MQClientAPIImpl.java

示例15: endTransactionOneway

import com.alibaba.rocketmq.common.UtilAll; //导入依赖的package包/类
/**
 * 提交或者回滚事务
 */
public void endTransactionOneway(//
        final String addr,//
        final EndTransactionRequestHeader requestHeader,//
        final String remark,//
        final long timeoutMillis//
) throws RemotingException, MQBrokerException, InterruptedException {
    // 添加虚拟运行环境相关的projectGroupPrefix
    if (!UtilAll.isBlank(projectGroupPrefix)) {
        requestHeader.setProducerGroup(VirtualEnvUtil.buildWithProjectGroup(
            requestHeader.getProducerGroup(), projectGroupPrefix));
    }

    RemotingCommand request =
            RemotingCommand.createRequestCommand(MQRequestCode.END_TRANSACTION_VALUE, requestHeader);
    request.setRemark(remark);
    this.remotingClient.invokeOneway(addr, request, timeoutMillis);
}
 
开发者ID:brucechan0921,项目名称:RocketMQ-3.0.8,代码行数:21,代码来源:MQClientAPIImpl.java


注:本文中的com.alibaba.rocketmq.common.UtilAll类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。