Find and retrieve resources by VTMOS例子出问题

WHW1984 2010-11-09 06:12:24
我看Tivoli的ncm_pdf_api_61.pdf文档,里面的Find and retrieve resources by VTMOS这个例子。
代码如下:
public void findAndRetrieveResourceByVTMOS()
{
ResourceManager rMgr;
ResourceContainerKey containerKey = null;
boolean subrealmsFlag = false;
String vendor = "*";
String type = "*";
String model = "*";
String os = "*";
try
{
rMgr = Connection.getInstance().apiSession.resourceManager();

// set up search criterion based on vendor/type/model/os
// setting a null value is the same as "*"
// for example setVendor(null) means the same as setVendor(*)
VtmosCriterion vtmos = rMgr.dataFactory().newVtmosCriterion();
vtmos.setVendor(vendor);
vtmos.setType(type);
vtmos.setModel(model);
vtmos.setOsVersion(os);

ResourceSearch rs = rMgr.dataFactory().newResourceSearch();
rs.setCriterion(vtmos);
rs.setResourceName(null);
// ArrayList<String> rTypeAL = new ArrayList<String>();
// rTypeAL.add(Resource.RESOURCE_COMMANDSET); // set resource type(s) as needed
// rs.setResourceTypes(rTypeAL);

ResourceContainerDescriptor realmRCD = rMgr.getContainer("root/3k");
if(realmRCD!=null){
containerKey = realmRCD.getKey();
}
rs.setStartingContainer(containerKey);
rs.setSubRealms(subrealmsFlag);

// now do the search
@SuppressWarnings("unchecked")
Collection<ResourceContentDescriptor> csDescs = rMgr.search(rs);//出错
if (csDescs == null || csDescs.isEmpty())
{
// handle case of no matches

} else
{
// for each descriptor, retrieve the corresponding CommandSet object
ArrayList<CommandSet> csColl = new ArrayList<CommandSet>();
Iterator<?> csDescIter = csDescs.iterator();
while (csDescIter.hasNext())
{
// retrieve the CommandSet for this descriptor.
ResourceContainerDescriptor tempRCD = (ResourceContainerDescriptor)csDescIter.next();
System.out.println(tempRCD.toString());
containerKey = tempRCD.getKey();
System.out.println(containerKey.toString());
ResourceContentDescriptor csDesc = tempRCD.getContentDescriptor();
if(csDesc!=null)
csColl.add((CommandSet) rMgr.getResource(csDesc));
}
}
} catch (Exception e)
{
e.printStackTrace();
}
}

错误信息:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2760)
at java.util.Arrays.copyOf(Arrays.java:2734)
at java.util.ArrayList.ensureCapacity(ArrayList.java:167)
at java.util.ArrayList.add(ArrayList.java:351)
at com.thoughtworks.xstream.io.xml.DomReader.reassignCurrentElement(DomReader.java:96)
at com.thoughtworks.xstream.io.xml.AbstractDocumentReader.moveUp(AbstractDocumentReader.java:51)
at com.thoughtworks.xstream.io.ReaderWrapper.moveUp(ReaderWrapper.java:29)
at com.thoughtworks.xstream.io.path.PathTrackingReader.moveUp(PathTrackingReader.java:31)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:59)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.unmarshal(CollectionConverter.java:50)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:56)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:45)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46)
at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:117)
at com.thoughtworks.xstream.core.ReferenceByXPathMarshallingStrategy.unmarshal(ReferenceByXPathMarshallingStrategy.java:29)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:846)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:833)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:781)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:773)
at com.intelliden.icos.api.impl.proxy.APIResponse.decode(APIResponse.java:10)
at com.intelliden.icos.api.impl.proxy.APICommunicator.executeMethod(APICommunicator.java:123)
at com.intelliden.icos.api.impl.proxy.APIInvocationHandler.invoke(APIInvocationHandler.java:32)
at $Proxy0.search(Unknown Source)
at com.NCMNotifier.findAndRetrieveResourceByVTMOS(NCMNotifier.java:190)
at com.NCMNotifier.main(NCMNotifier.java:709)
...全文
88 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
chenxin6628 2011-07-07
  • 打赏
  • 举报
回复
内存溢出,你把内存多分配一些,并且读入内存的操作时,最好分批次读入。
WHW1984 2010-11-10
  • 打赏
  • 举报
回复
没人使用这个东西吗?

2,679

社区成员

发帖
与我相关
我的任务
社区描述
企业开发 ERP/CRM
社区管理员
  • ERP/CRM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧