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


Java HttpUtil类代码示例

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


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

示例1: cancel

import org.pentaho.di.cluster.HttpUtil; //导入依赖的package包/类
public synchronized void cancel() throws SQLException {
  
  // Kill the service transformation on the server...
  // Only ever try once.
  //
  if (!stopped.get()) {
    stopped.set(true);
    try {
      String reply = HttpUtil.execService(new Variables(), 
          connection.getHostname(), connection.getPort(), connection.getWebAppName(), 
          connection.getService()+"/stopTrans"+"/?name="+URLEncoder.encode(serviceTransName, "UTF-8")+"&id="+Const.NVL(serviceObjectId, "")+"&xml=Y",
          connection.getUsername(), connection.getPassword(), 
          connection.getProxyHostname(), connection.getProxyPort(), connection.getNonProxyHosts());
      
      WebResult webResult = new WebResult(XMLHandler.loadXMLString(reply, WebResult.XML_TAG));
      if (!"OK".equals(webResult.getResult())) {
        throw new SQLException("Cancel on remote server failed: "+webResult.getMessage());
      }
      
    } catch(Exception e) {
      throw new SQLException("Couldn't cancel SQL query on slave server", e);
    }
  }
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:25,代码来源:ThinResultSet.java

示例2: checkTransStatus

import org.pentaho.di.cluster.HttpUtil; //导入依赖的package包/类
private void checkTransStatus(String transformationName, String transformationObjectId) throws SQLException {
  try {
    String xml = HttpUtil.execService(new Variables(), 
        connection.getHostname(), connection.getPort(), connection.getWebAppName(), 
        connection.getService()+"/transStatus/?name="+URLEncoder.encode(transformationName, "UTF-8")+"&id="+Const.NVL(transformationObjectId, "")+"&xml=Y", 
        connection.getUsername(), connection.getPassword(), connection.getProxyHostname(), connection.getProxyPort(), connection.getNonProxyHosts()
      );
    Document doc = XMLHandler.loadXMLString(xml);
    Node resultNode = XMLHandler.getSubNode(doc, "transstatus", "result");
    Result result = new Result(resultNode);
    String loggingString64 = XMLHandler.getNodeValue(XMLHandler.getSubNode(doc, "transstatus", "logging_string"));
    String log = HttpUtil.decodeBase64ZippedString(loggingString64);

    // Check for errors
    //
    if (!result.getResult() || result.getNrErrors()>0) {
      throw new KettleException("The SQL query transformation failed with the following log text:"+Const.CR+log);
    }

    // See if the transformation was stopped remotely
    //
    boolean stopped = "Stopped".equalsIgnoreCase(XMLHandler.getTagValue(doc, "transstatus", "status_desc"));
    if (stopped) {
      throw new KettleException("The SQL query transformation was stopped.  Logging text: "+Const.CR+log);
    }

    // All OK, only log the remote logging text if requested.
    //
    if (connection.isDebuggingRemoteLog()) {
      LogChannel.GENERAL.logBasic(log); 
    }
    
  } catch(Exception e) {
    throw new SQLException("Couldn't validate correct execution of SQL query for transformation ["+transformationName+"]", e);
  }

}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:38,代码来源:ThinResultSet.java

示例3: getServiceInformation

import org.pentaho.di.cluster.HttpUtil; //导入依赖的package包/类
public List<ThinServiceInformation> getServiceInformation() throws SQLException {
  try {
    String xml = HttpUtil.execService(new Variables(),
        connection.getHostname(), connection.getPort(), connection.getWebAppName(), 
        serviceUrl, connection.getUsername(), connection.getPassword(), 
        connection.getProxyHostname(), connection.getProxyPort(), connection.getNonProxyHosts()
       );

    List<ThinServiceInformation> services = new ArrayList<ThinServiceInformation>();
    
    Document doc = XMLHandler.loadXMLString(xml);
    Node servicesNode = XMLHandler.getSubNode(doc, "services");
    List<Node> serviceNodes = XMLHandler.getNodes(servicesNode, "service");
    for (Node serviceNode : serviceNodes) {
      
      String name = XMLHandler.getTagValue(serviceNode, "name");
      Node rowMetaNode = XMLHandler.getSubNode(serviceNode, RowMeta.XML_META_TAG);
      RowMetaInterface serviceFields = new RowMeta(rowMetaNode);
      ThinServiceInformation service = new ThinServiceInformation(name, serviceFields);
      services.add(service);
    }
    
    return services;
  } catch(Exception e) {
    throw new SQLException("Unable to get service information from server", e);
  }

}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:29,代码来源:ThinDatabaseMetaData.java

示例4: getTestObject

import org.pentaho.di.cluster.HttpUtil; //导入依赖的package包/类
@Override
public String getTestObject() {
  try {
    return HttpUtil.encodeBase64ZippedString( UUID.randomUUID().toString() );
  } catch ( IOException e ) {
    throw new RuntimeException( e );
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:9,代码来源:SlaveServerJobStatusTest.java

示例5: validateTestObject

import org.pentaho.di.cluster.HttpUtil; //导入依赖的package包/类
@Override
public boolean validateTestObject( String testObject, Object actual ) {
  try {
    return HttpUtil.decodeBase64ZippedString( testObject ).equals( actual );
  } catch ( IOException e ) {
    throw new RuntimeException( e );
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:9,代码来源:SlaveServerJobStatusTest.java

示例6: parseUrl

import org.pentaho.di.cluster.HttpUtil; //导入依赖的package包/类
private void parseUrl() throws SQLException {
  
  if (!url.startsWith(ThinDriver.BASE_URL)) {
    throw new SQLException("Invalid url for this driver: "+url+", not starting with "+ThinDriver.BASE_URL);
  }
  
  // Example URLs : 
  //
  //   jdbc:pdi://slaveserver:8181/kettle/?webappname=pdi&proxyserver=proxy1&parameter_area=EAST
  //
  // converts to:
  //
  //   http://cluster:[email protected]:8181/kettle/?webappname=pdi&proxyserver=proxy1&parameter_area=EAST
  //
  
  try {
    int portColonIndex = url.indexOf(':', ThinDriver.BASE_URL.length());
    
    hostname = url.substring(ThinDriver.BASE_URL.length(), portColonIndex);
    int kettleIndex = url.indexOf(ThinDriver.SERVICE_NAME, portColonIndex);
    port = url.substring(portColonIndex+1, kettleIndex);
    service = ThinDriver.SERVICE_NAME;
    int startIndex = url.indexOf('?', kettleIndex)+1;
    arguments = new HashMap<String, String>();
    if (startIndex>0) {
      // Correct the path, exclude the arguments
      //
      String path=url.substring(startIndex);
      String[] args = path.split("\\&");
      for (String arg : args) {
        String[] parts = arg.split("=");
        if (parts.length==2) {
          arguments.put(parts[0], parts[1]);
        }
      }
    }
    
    slaveBaseAddress = "http://"+hostname+":"+port+service;
    
    // Determine the web app name
    //
    webAppName = arguments.get(ARG_WEBAPPNAME);
    proxyHostname = arguments.get(ARG_PROXYHOSTNAME);
    proxyPort= arguments.get(ARG_PROXYPORT);
    nonProxyHosts= arguments.get(ARG_NONPROXYHOSTS);
    debugTransFilename = arguments.get(ARG_DEBUGTRANS);
    debuggingRemoteLog = "true".equalsIgnoreCase(arguments.get(ARG_DEBUGLOG));
    
    // Try to get a status from the carte server to see if the connection works...
    //
    HttpUtil.execService(new Variables(), 
        hostname, port, webAppName, service+"/status/", username, password, 
        proxyHostname, proxyPort, nonProxyHosts);
    
  } catch (Exception e) {
    throw new SQLException("Unable to de-compose slave server address for URL: "+slaveBaseAddress, e);
  }
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:59,代码来源:ThinConnection.java


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