Search in sources :

Example 1 with IMyDubboService

use of com.creditease.monitorframework.fat.dubbo.IMyDubboService in project uavstack by uavorg.

the class TestRestService method testDubbo.

@POST
@Path("testDubbo")
public String testDubbo() {
    WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(sc);
    IMyDubboService mds = (IMyDubboService) wac.getBean("myDubboServiceC");
    return mds.sayHello("zz");
}
Also used : IMyDubboService(com.creditease.monitorframework.fat.dubbo.IMyDubboService) WebApplicationContext(org.springframework.web.context.WebApplicationContext) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 2 with IMyDubboService

use of com.creditease.monitorframework.fat.dubbo.IMyDubboService in project uavstack by uavorg.

the class TestRestService method testDubboUncatchException.

@POST
@Path("testDubboUncatchException")
public String testDubboUncatchException() {
    WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(sc);
    IMyDubboService mds = (IMyDubboService) wac.getBean("myDubboServiceC");
    return mds.sayUncatchException("UncatchException");
}
Also used : IMyDubboService(com.creditease.monitorframework.fat.dubbo.IMyDubboService) WebApplicationContext(org.springframework.web.context.WebApplicationContext) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 3 with IMyDubboService

use of com.creditease.monitorframework.fat.dubbo.IMyDubboService in project uavstack by uavorg.

the class TestRestService method testDubboExceptin.

@POST
@Path("testDubboExceptin")
public String testDubboExceptin() throws IOException {
    WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(sc);
    IMyDubboService mds = (IMyDubboService) wac.getBean("myDubboServiceC");
    return mds.sayException("exception");
}
Also used : IMyDubboService(com.creditease.monitorframework.fat.dubbo.IMyDubboService) WebApplicationContext(org.springframework.web.context.WebApplicationContext) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 4 with IMyDubboService

use of com.creditease.monitorframework.fat.dubbo.IMyDubboService in project uavstack by uavorg.

the class ChainService method circleTest.

@GET
@Path("circle_test")
public String circleTest(@QueryParam("time") int time) throws SQLException {
    if (time == 10) {
        return "";
    }
    // 首先进行redis读写操作
    System.out.println("Jedis OPS======================================================");
    Jedis jedis = new Jedis("localhost", 6379);
    jedis.set("foo", "bar");
    jedis.get("foo");
    jedis.close();
    // 进行服务之间交互
    CloseableHttpClient client = HttpClients.createDefault();
    HttpUriRequest http = new HttpGet("http://localhost:8080/com.creditease.uav.monitorframework.buildFat/rs/http/httpclienttest");
    try {
        HttpResponse resp1 = client.execute(http);
        System.out.println(resp1.getStatusLine());
        client.close();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    // ws调用begin
    TestService_Service s = new TestService_Service();
    TestService ts = s.getTestServicePort();
    // 设置客户端的配置信息,超时等.
    Client proxy = ClientProxy.getClient(ts);
    HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
    HTTPClientPolicy policy = new HTTPClientPolicy();
    // 连接服务器超时时间
    policy.setConnectionTimeout(30000);
    // 等待服务器响应超时时间
    policy.setReceiveTimeout(30000);
    conduit.setClient(policy);
    ts.echo();
    // ws调用end
    // mysql调用
    Connection c = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/testdb", "root", "root");
    System.out.println("Statement -------------------->");
    Statement st = c.createStatement();
    st.execute("insert into mytest values (1,'zz',23)");
    st.close();
    System.out.println("PreparedStatement -------------------->");
    PreparedStatement ps = c.prepareStatement("insert into mytest values (?,?,?)");
    ps.setInt(1, 1);
    ps.setString(2, "zz");
    ps.setInt(3, 23);
    ps.execute();
    ps.close();
    ps = c.prepareStatement("select name from mytest where id=?");
    ps.setInt(1, 1);
    ps.executeQuery();
    ps.close();
    ps = c.prepareStatement("update mytest set age=24 where id=?");
    ps.setInt(1, 1);
    ps.executeUpdate();
    ps.close();
    ps = c.prepareStatement("delete from mytest where id=?");
    ps.setInt(1, 1);
    ps.executeUpdate();
    ps.close();
    c.close();
    // mongo
    MongoClient mongoClient = new MongoClient();
    mongoClient.listDatabaseNames().first();
    MongoDatabase db = mongoClient.getDatabase("apphubDataStore");
    db.listCollectionNames().first();
    MongoCollection<Document> collection = db.getCollection("test");
    collection.listIndexes().first();
    Document doc = new Document("name", "Amarcord Pizzeria").append("contact", new Document("phone", "264-555-0193").append("email", "amarcord.pizzeria@example.net").append("location", Arrays.asList(-73.88502, 40.749556))).append("stars", 2).append("categories", Arrays.asList("Pizzeria", "Italian", "Pasta"));
    collection.insertOne(doc);
    collection.find().first();
    mongoClient.close();
    // 进行服务之间交互
    CloseableHttpClient client2 = HttpClients.createDefault();
    time++;
    HttpUriRequest http2 = new HttpGet("http://localhost:8080/com.creditease.uav.monitorframework.buildFat/rs/chain/circle_test" + "?time=" + time);
    try {
        HttpResponse resp1 = client2.execute(http2);
        System.out.println(resp1.getStatusLine());
        client2.close();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    // dubbo调用begin
    WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(sc);
    IMyDubboService mds = (IMyDubboService) wac.getBean("myDubboServiceC");
    mds.sayHello("zz");
    return "circle test perfect";
}
Also used : HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) TestService_Service(com.creditease.monitorframework.fat.client.TestService_Service) TestService(com.creditease.monitorframework.fat.client.TestService) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) HttpGet(org.apache.http.client.methods.HttpGet) Connection(java.sql.Connection) HttpResponse(org.apache.http.HttpResponse) PreparedStatement(java.sql.PreparedStatement) IOException(java.io.IOException) Document(org.bson.Document) ClientProtocolException(org.apache.http.client.ClientProtocolException) WebApplicationContext(org.springframework.web.context.WebApplicationContext) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) Jedis(redis.clients.jedis.Jedis) MongoClient(com.mongodb.MongoClient) IMyDubboService(com.creditease.monitorframework.fat.dubbo.IMyDubboService) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) Client(org.apache.cxf.endpoint.Client) MongoClient(com.mongodb.MongoClient) MongoDatabase(com.mongodb.client.MongoDatabase) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

IMyDubboService (com.creditease.monitorframework.fat.dubbo.IMyDubboService)4 Path (javax.ws.rs.Path)4 WebApplicationContext (org.springframework.web.context.WebApplicationContext)4 POST (javax.ws.rs.POST)3 TestService (com.creditease.monitorframework.fat.client.TestService)1 TestService_Service (com.creditease.monitorframework.fat.client.TestService_Service)1 MongoClient (com.mongodb.MongoClient)1 MongoDatabase (com.mongodb.client.MongoDatabase)1 IOException (java.io.IOException)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 Statement (java.sql.Statement)1 GET (javax.ws.rs.GET)1 Client (org.apache.cxf.endpoint.Client)1 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)1 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)1 HttpResponse (org.apache.http.HttpResponse)1 ClientProtocolException (org.apache.http.client.ClientProtocolException)1 HttpGet (org.apache.http.client.methods.HttpGet)1 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)1