Package com.sun.faban.harness.tools

Examples of com.sun.faban.harness.tools.MasterToolContext


                        for (String t1 : toolsetTools) {
                            StringTokenizer tt1 = new StringTokenizer(t1);
                            String toolId1 = tt1.nextToken();
                            String toolKey1 = toolId1 + '/' + serviceName;
                            ToolDescription toolDesc = toolMap.get(toolKey1);
                            MasterToolContext toolCtx;
                            if (toolDesc != null) {
                                toolCtx = new MasterToolContext(t1, ctx,
                                        toolDesc);
                            } else {
                                toolDesc = toolMap.get(toolId1);
                                if (toolDesc != null) {
                                    toolCtx = new MasterToolContext(
                                            t1, ctx, toolDesc);
                                    activeDeployments.add(
                                            toolDesc.getLocationType() +
                                                    File.separator +
                                                    toolDesc.getLocation());
                                } else {
                                    //logger.info("No Tool Description for tool: " + t1);
                                    logger.fine("No Tool Description for tool: "
                                            + t1 +" ,so it's a command line tool");
                                    toolCtx = new MasterToolContext(
                                            t1, ctx, null);
                                }
                            }
                            if (toolCtx != null) {
                                toolList.add(toolCtx);
                            }
                        }
                    }

                }
                // Analyze the list of tools for toolset references.
                for (String tool : tools) {
                    StringTokenizer tt = new StringTokenizer(tool);
                    String toolId = tt.nextToken();
                    String toolKey = toolId + '/' + serviceName;
                    Set<String> toolsetTools = new LinkedHashSet<String>();
                    if (toolSetsMap.containsKey(toolKey)) {
                        toolsetTools.addAll(toolSetsMap.get(toolKey));
                        for (String t1 : toolsetTools) {
                            StringTokenizer tt1 = new StringTokenizer(t1);
                            String toolId1 = tt1.nextToken();
                            String toolKey1 = toolId1 + '/' + serviceName;
                            ToolDescription toolDesc = toolMap.get(toolKey1);
                            MasterToolContext toolCtx;
                            if (toolDesc != null) {
                                toolCtx = new MasterToolContext(t1, ctx, toolDesc);
                            } else {
                                toolDesc = toolMap.get(toolId1);
                                if (toolDesc != null) {
                                    toolCtx = new MasterToolContext(
                                            t1, ctx, toolDesc);
                                } else {
                                    logger.fine("No Tool Description for tool: "
                                            + t1 +
                                            " ,so it's a command line tool");
                                    toolCtx = new MasterToolContext(
                                            t1, ctx, null);
                                }
                            }
                            if (toolCtx != null) {
                                toolList.add(toolCtx);
                            }
                        }
                    } else {
                        ToolDescription toolDesc = toolMap.get(toolKey);
                        MasterToolContext toolCtx;
                        if (toolDesc != null) {
                            toolCtx = new MasterToolContext(tool, ctx, toolDesc);
                        } else {
                            toolDesc = toolMap.get(toolId);
                            if (toolDesc != null) {
                                toolCtx = new MasterToolContext(
                                        tool, ctx, toolDesc);
                            } else {
                                logger.fine("No Tool Description for tool: " +
                                        tool + " ,so it's a command line tool");
                                toolCtx = new MasterToolContext(
                                        tool, ctx, null);
                            }
                        }
                        if (toolCtx != null) {
                            toolList.add(toolCtx);
                        }
                    }
                }
                for (MasterToolContext toolCtx : toolList) {
                    String locationType;
                    if (toolCtx.getToolDescription() != null) {
                        locationType =
                            toolCtx.getToolDescription().getLocationType();
                        if ("services".equals(locationType)) {
                            String location =
                                    toolCtx.getToolDescription().getLocation();
                            String fullLocation = locationType + '/' + location;
                            activeDeployments.add(fullLocation);

                            CmdService cmds = CmdService.getHandle();
                            String[] ctxHosts =
                                    toolCtx.getToolServiceContext().getHosts();
                            for (String ctxHost : ctxHosts) {
                                if (hostDeploymentSet.add(new NameValuePair<String>(
                                        cmds.getHostName(ctxHost), location))) {
                                    hostDeploymentList.add(new NameValuePair<String>
                                            (ctxHost, location));
View Full Code Here


                String toolId = tt.nextToken();
                Set<String> toolsetTools = new LinkedHashSet<String>();
                if (toolSetsMap.containsKey(toolId)) {
                    toolsetTools.addAll(toolSetsMap.get(toolId));
                    for (String t1 : toolsetTools) {
                        MasterToolContext tCtx = new MasterToolContext(
                                t1, null, null);
                        if (tCtx != null) {
                            toollist.add(tCtx);
                        }
                    }
                } else {
                    MasterToolContext tCtx = new MasterToolContext(
                            tool, null, null);
                    if (tCtx != null) {
                        toollist.add(tCtx);
                    }
                }
            }
        }
        numTools = toollist.size();
        toolNames = new String[numTools];
        tools = new ToolWrapper[numTools];

        logger.fine("Processing tools");
        latch = new CountDownLatch(toollist.size());
       
        for (int i=0; i<toollist.size(); i++) {
            MasterToolContext ctx = toollist.get(i);
            String toolId = ctx.getToolId();
            toolNames[i] = toolId;
            //List<String> args = Command.parseArgs(ctx.getToolParams());
          

            String path = null;
            int nameIdx = toolId.lastIndexOf(File.separator) + 1;
            if (nameIdx > 0) {
                path = toolId.substring(0, nameIdx - 1);
                toolId = toolId.substring(nameIdx);
            }

            if (path != null && path.length() == 0)
                path = null;

            String toolClass = null;
            ToolDescription toolDesc = ctx.getToolDescription();
            if (toolDesc != null)
                toolClass = toolDesc.getToolClass();

            // Now, create the tool object and call its configure method           
            if (toolClass != null) {
                try {
                    DeployImageClassLoader loader = DeployImageClassLoader.
                            getInstance(toolDesc.getLocationType(),
                            toolDesc.getLocation(), getClass().getClassLoader());
                    Class c = loader.loadClass(toolClass);
                    tools[i] = new ToolWrapper(c, ctx);
                    logger.fine("Trying to run tool " + c.getName());
                    tools[i].configure(toolNames[i], path, outDir, host, CmdAgentImpl.getHandle(), latch);
                } catch (ClassNotFoundException ce) {
                    logger.log(Level.WARNING, "Class " + toolClass + " not found");
                    latch.countDown();
                } catch (Exception ie) {
                    logger.log(Level.WARNING, "Error in creating tool object " +
                               toolClass, ie);
                    latch.countDown(); // Tool did not get started.
                }
            } else if (!"default".equals(ctx.getToolId()) ||
                       (ctx.getToolParams() != null &&
                        ctx.getToolParams().trim().length() > 0)) {
                try {
                    tools[i] = new ToolWrapper(CommandLineTool.class, ctx);
                    tools[i].configure(toolNames[i], path, outDir, host, CmdAgentImpl.getHandle(), latch);
                    logger.fine("Trying to run tool " + tools[i] + " using CommandLineTool.");
                } catch (Exception ex) {
View Full Code Here

TOP

Related Classes of com.sun.faban.harness.tools.MasterToolContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.