Package com.bj58.spat.gaea.client.loadbalance

Examples of com.bj58.spat.gaea.client.loadbalance.Server


*/
public class PathMatcherTest {

    @Test
    public void test() {
        PathMatcher pathMatcher = new AntPathMatcher();

        String pattern = "/{a}/{b}/{c}";

        String sample = "/aa/bb/cc";

        Assert.assertTrue(pathMatcher.match(pattern, sample));

    }
View Full Code Here


    }


    @Test
    public void testPathMatch(){
        PathMatcher pathMatcher = new AntPathMatcher();
        String registeredPath = "/me/hello/{name}";
        String url = "/me/hello/renjun";
        Assert.assertTrue(pathMatcher.match(registeredPath, url));

        Map<String, String> values = pathMatcher.extractUriTemplateVariables(registeredPath, url);
        Assert.assertEquals(1, values.size());
        Assert.assertEquals("renjun", values.get("name"));

        System.out.println("OK testpathMatch");
View Full Code Here

        InputStream in = new BufferedInputStream(request.getInputStream());
        String content_type = request.getContentType();

        File tempDir = new File(config.getLocation());

        MultiPartInputStreamParser mpis = new MultiPartInputStreamParser(in, content_type, config, tempDir);
        mpis.setDeleteOnExit(true);
        return mpis;
    }
View Full Code Here

        InputStream in = new BufferedInputStream(super.getInputStream());
        String content_type = super.getContentType();

        File tempDir = new File(config.getLocation());

        multiParser = new MultiPartInputStreamParser(in, content_type, config, tempDir);
        multiParser.setDeleteOnExit(true);

        Collection<Part> parts = multiParser.getParts();

        int keyCount = queryStrings.size();
View Full Code Here

*/
public class EnterpriseUserTest {

  @Test
  public void TestUser() throws Exception {
    SESUser user = new SESUser();
    user.setUserID(1L);
    user.setState(1);

    Serializer serializer = new Serializer();
    byte[] buffer = serializer.Serialize(user);
    assertNotNull(buffer);
    Object obj = serializer.Derialize(buffer, SimpleClass.class);
View Full Code Here

            config.getProtocol().getSerializerType(),
            PlatformType.Java,
            requestProtocol);
       
        Protocol receiveP = null;
        Server server = null;
       
        for(int i = 0; i <= count; i++){
          server = dispatcher.GetServer();
            if (server == null) {
                logger.error("cannot get server");
                throw new Exception("cannot get server");
            }
            try{
              receiveP = server.request(sendP);
              break;
            } catch(IOException io){
              if(count == 0 || i == ioreconnect){
                throw io;
              }
              if(i < count && i < ioreconnect) {
                logger.error(server.getName()+" server has IOException,system will change normal server!");
                continue;
              }
            } catch(RebootException rb){
              this.createReboot(server);
              if(count == 0 || i == ioreconnect){
                throw new IOException("connect fail!");
              }
              if(i < count && i < ioreconnect) {
                logger.error(server.getName()+" server has reboot,system will change normal server!");
                continue;
              }
            }catch(TimeoutException te){
              if(count == 0 || i == requestTime){
                throw new TimeoutException("Receive data timeout or error!");
              }
              if(i < count && i < requestTime) {
                logger.error(server.getName()+" server has TimeoutException,system will change normal server!");
                continue;
              }
            } catch (Throwable ex){
              logger.error("invoke other Exception", ex);
              throw ex;
            }
      }
       
        if(receiveP == null){
          throw new Exception("userdatatype error!");
        }
       
        if (receiveP.getSDPType() == SDPType.Response) {
            ResponseProtocol rp = (ResponseProtocol)receiveP.getSdpEntity();
            logger.debug("invoke time:" + (System.currentTimeMillis() - watcher) + "ms");
            return new InvokeResult(rp.getResult(), rp.getOutpara());
        } else if(receiveP.getSDPType() == SDPType.Reset){ //服务重启
          logger.info(server.getName()+" server is reboot,system will change normal server!");
          this.createReboot(server);
          return invoke(returnType, typeName, methodName, paras);
        }else if (receiveP.getSDPType() == SDPType.Exception) {
            ExceptionProtocol ep = (ExceptionProtocol)receiveP.getSdpEntity();
            throw ThrowErrorHelper.throwServiceError(ep.getErrorCode(), ep.getErrorMsg());
View Full Code Here

     *  get Server info
     * @param name Server name
     * @return if Server exist return Server info else return empty
     */
    public String getServer(String name) {
        Server server = dispatcher.GetServer(name);
        if (server == null) {
            return "";
        }
        return server.toString();
    }
View Full Code Here

      }
    }
  }
 
  public void ContextException(GaeaContext context,Protocol protocol,GaeaResponse response,String message) throws Exception{
    ExceptionProtocol ep = ExceptionHelper.createError(new Exception());
    ep.setErrorMsg(message);
    protocol.setSdpEntity(ep);
    response.setResponseBuffer(protocol.toBytes());
    context.setGaeaResponse(response);
    this.setInvokeAndFilter(context);
  }
View Full Code Here

      }
    }
  }
 
  public void ContextException(GaeaContext context,Protocol protocol,GaeaResponse response,String message,boolean bool,byte[] key) throws Exception{
    ExceptionProtocol ep = ExceptionHelper.createError(new Exception());
    ep.setErrorMsg(message);
    protocol.setSdpEntity(ep);
    response.setResponseBuffer(protocol.toBytes(bool,key));
    context.setGaeaResponse(response);
    this.setInvokeAndFilter(context);
  }
View Full Code Here

    context.setGaeaResponse(response);
    this.setInvokeAndFilter(context);
  }
 
  public void ContextException(GaeaContext context,Protocol protocol,GaeaResponse response,String message) throws Exception{
    ExceptionProtocol ep = ExceptionHelper.createError(new Exception());
    ep.setErrorMsg(message);
    protocol.setSdpEntity(ep);
    response.setResponseBuffer(protocol.toBytes());
    context.setGaeaResponse(response);
    this.setInvokeAndFilter(context);
  }
View Full Code Here

TOP

Related Classes of com.bj58.spat.gaea.client.loadbalance.Server

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.