當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。