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


Java TaskInfo.hasData方法代码示例

本文整理汇总了Java中org.apache.mesos.Protos.TaskInfo.hasData方法的典型用法代码示例。如果您正苦于以下问题:Java TaskInfo.hasData方法的具体用法?Java TaskInfo.hasData怎么用?Java TaskInfo.hasData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.mesos.Protos.TaskInfo的用法示例。


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

示例1: pack

import org.apache.mesos.Protos.TaskInfo; //导入方法依赖的package包/类
/**
 * Packs the TaskInfo in preparation for sending it to the Executor. For a description of how the packing works
 * (and why it exists), see the class-level javadoc.
 *
 * @see #unpack(TaskInfo)
 */
public static TaskInfo pack(TaskInfo taskInfo) {
    if (!taskInfo.hasExecutor()) {
        return taskInfo;
    } else {
        ExecutorInfo.Builder executorInfoBuilder = ExecutorInfo.newBuilder()
                .setExecutorId(ExecutorID.newBuilder().setValue(COMMAND_DATA_PACKAGE_EXECUTORID));

        if (taskInfo.hasCommand()) {
            executorInfoBuilder.setCommand(taskInfo.getCommand());
        }

        if (taskInfo.hasData()) {
            executorInfoBuilder.setData(taskInfo.getData());
        }

        return TaskInfo.newBuilder(taskInfo)
                .setData(executorInfoBuilder.build().toByteString())
                .clearCommand()
                .build();
    }
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:28,代码来源:TaskPackingUtils.java

示例2: unpack

import org.apache.mesos.Protos.TaskInfo; //导入方法依赖的package包/类
/**
 * This method reverses the work done in {@link TaskPackingUtils#pack(TaskInfo)} such that the original TaskInfo is
 * regenerated. If the provided {@link TaskInfo} doesn't appear to have packed data then this operation does
 * nothing.
 *
 * @see #pack(TaskInfo)
 */
public static TaskInfo unpack(TaskInfo taskInfo) {
    if (!taskInfo.hasData() || !taskInfo.hasExecutor()) {
        return taskInfo;
    } else {
        TaskInfo.Builder taskBuilder = TaskInfo.newBuilder(taskInfo);
        ExecutorInfo pkgExecutorInfo;
        try {
            pkgExecutorInfo = ExecutorInfo.parseFrom(taskInfo.getData());
        } catch (InvalidProtocolBufferException e) {
            // In practice this shouldn't happen. This TaskInfo has a data field, but it doesn't parse as an
            // ExecutorInfo. Let's assume this means that the TaskInfo isn't packed and return it as-is.
            return taskInfo;
        }

        if (pkgExecutorInfo.hasCommand()) {
            taskBuilder.setCommand(pkgExecutorInfo.getCommand());
        }

        if (pkgExecutorInfo.hasData()) {
            taskBuilder.setData(pkgExecutorInfo.getData());
        } else {
            taskBuilder.clearData();
        }

        return taskBuilder.build();
    }
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:35,代码来源:TaskPackingUtils.java


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