• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java TaskFilterSpec类的典型用法和代码示例

java 4次浏览

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

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

示例1: getTaskInfo

点赞 2

import com.vmware.vim25.TaskFilterSpec; //导入依赖的package包/类
protected TaskInfo getTaskInfo(VMwareClient vmw,
        VMPropertyHandler paramHandler) throws Exception {

    String instanceId = paramHandler.getInstanceName();
    String taskKey = paramHandler
            .getServiceSetting(VMPropertyHandler.TASK_KEY);
    logger.debug("VM: " + instanceId + " taskId: " + taskKey);
    if (taskKey == null || "".equals(taskKey)) {
        return null;
    }

    VimPortType service = vmw.getConnection().getService();
    ManagedObjectReference taskManager = vmw.getConnection()
            .getServiceContent().getTaskManager();
    ManagedObjectReference taskHistoryCollector = service
            .createCollectorForTasks(taskManager, new TaskFilterSpec());
    try {
        service.resetCollector(taskHistoryCollector);
        service.readNextTasks(taskHistoryCollector, 100);
        List<TaskInfo> taskList = vmw.getConnection().getService()
                .readPreviousTasks(taskHistoryCollector, 100);

        if (taskList != null) {
            for (TaskInfo taskInfo : taskList) {
                if (taskInfo != null && taskKey.equals(taskInfo.getKey())) {
                    logTaskInfo(taskInfo);
                    return taskInfo;
                }
            }
        }

        logger.error("Task not found. VM: " + instanceId + " taskId: "
                + taskKey);
        return null;
    } finally {
        service.destroyCollector(taskHistoryCollector);
    }
}
 

开发者ID:servicecatalog,
项目名称:oscm,
代码行数:39,
代码来源:Actions.java

示例2: createTaskFilterSpec

点赞 2

import com.vmware.vim25.TaskFilterSpec; //导入依赖的package包/类
static TaskFilterSpec createTaskFilterSpec(ManagedEntity ent)
{
  TaskFilterSpec tfs = new TaskFilterSpec();
  
  // only the root initiated tasks
  TaskFilterSpecByUsername nameFilter 
    = new TaskFilterSpecByUsername();
  nameFilter.setUserList(new String[] {"Administrator"});
  // include tasks initiated by non-users, 
  // for example, by ScheduledTaskManager.
  nameFilter.setSystemUser(true);
  tfs.setUserName(nameFilter);
  
  // only the tasks with one entity itself
  TaskFilterSpecByEntity entFilter = 
    new TaskFilterSpecByEntity();
  entFilter.setEntity(ent.getMOR());
  entFilter.setRecursion(TaskFilterSpecRecursionOption.all);
  tfs.setEntity(entFilter);
  
  // only successfully finished tasks
  tfs.setState(new TaskInfoState[]{TaskInfoState.success });
  
  // only tasks started within last one month
  // strictly speaking, time should be retrieved from server
  TaskFilterSpecByTime tFilter =new TaskFilterSpecByTime();
  Calendar cal = Calendar.getInstance();
  cal.roll(Calendar.MONTH, -1);
  tFilter.setBeginTime(cal); 
  //we ignore the end time here so it gets the latest.
  tFilter.setTimeType(TaskFilterSpecTimeOption.startedTime);
  tfs.setTime(tFilter);
  
  // Optionally, you limits tasks initiated by scheduled task
  // with the setScheduledTask() method. 
  return tfs;
}
 

开发者ID:Juniper,
项目名称:vijava
代码行数:38,
代码来源:TaskHistoryMonitor.java

示例3: main

点赞 2

import com.vmware.vim25.TaskFilterSpec; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
  if(args.length != 3)
  {
    System.out.println("Usage: java TaskHistoryMonitor " 
      + "<url> <username> <password>");
    return;
  }
   
  ServiceInstance si = new ServiceInstance(
    new URL(args[0]), args[1], args[2], true);
   
  TaskManager taskMgr = si.getTaskManager();

  if(taskMgr!=null)
  {
    Folder root = si.getRootFolder();
    TaskFilterSpec tfs = createTaskFilterSpec(root); 
    TaskHistoryCollector thc = 
        taskMgr.createCollectorForTasks(tfs);
    
    // Note: 10 <= pagesize <= 62
    thc.setCollectorPageSize(15);

    System.out.println("Tasks in latestPage:");
    TaskInfo[] tis = thc.getLatestPage();
    printTaskInfos(tis);

    System.out.println("\nAll tasks:");
    int total = 0; 
    
    while(true)
    {
      tis= thc.readNextTasks(50);
      if(tis==null)
      {
        break;
      }
      total += tis.length;
      printTaskInfos(tis);
    }
    System.out.println("\nTotal number " +
    		"of tasks retrieved:" + total);
    thc.destroyCollector();
  }
  si.getServerConnection().logout();
}
 

开发者ID:Juniper,
项目名称:vijava
代码行数:48,
代码来源:TaskHistoryMonitor.java

示例4: createCollectorForTasks

点赞 1

import com.vmware.vim25.TaskFilterSpec; //导入依赖的package包/类
TaskHistoryCollector createCollectorForTasks(TaskFilterSpec filter) throws InvalidState, RuntimeFault, RemoteException; 

开发者ID:igreenfield,
项目名称:jcloud-vsphere,
代码行数:2,
代码来源:TaskManagerApi.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)