diff --git a/protocol/dubbo/dubbo_codec.go b/protocol/dubbo/dubbo_codec.go index 12ab408d08737f9c7036768e77c6a3975536903e..f297d4c3d41ae97e2b0bd72283aa956ec209eb5f 100644 --- a/protocol/dubbo/dubbo_codec.go +++ b/protocol/dubbo/dubbo_codec.go @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package dubbo import ( @@ -114,12 +130,6 @@ func (c *DubboCodec) EncodeRequest(request *remoting.Request) (*bytes.Buffer, er panic(err) } p.Service.Timeout = time.Duration(timeout) - //var timeout = request.svcUrl.GetParam(strings.Join([]string{constant.METHOD_KEYS, request.method + constant.RETRIES_KEY}, "."), "") - //if len(timeout) != 0 { - // if t, err := time.ParseDuration(timeout); err == nil { - // p.Service.Timeout = t - // } - //} p.Header.SerialID = byte(S_Dubbo) p.Header.ID = request.Id @@ -322,12 +332,5 @@ func (c *DubboCodec) decodeResponse(data []byte) (*remoting.Response, int, error rpcResult.Rest = pkg.Body.(*hessian.Response).RspObj } - //h.conn.updateSession(session) - //pendingResponse := h.conn.pool.rpcClient.removePendingResponse(SequenceType(p.Header.ID)) - //if pendingResponse == nil { - // logger.Errorf("failed to get pending response context for response package %s", *p) - // return - //} - return response, hessian.HEADER_LENGTH + pkg.Header.BodyLen, nil } diff --git a/protocol/dubbo/dubbo_codec_test.go b/protocol/dubbo/dubbo_codec_test.go deleted file mode 100644 index f401318d86115f58578a6470227ea6e6afe811a7..0000000000000000000000000000000000000000 --- a/protocol/dubbo/dubbo_codec_test.go +++ /dev/null @@ -1 +0,0 @@ -package dubbo diff --git a/remoting/codec.go b/remoting/codec.go index 1c1e0257626801586e9445c4a0ac4aec6631d4d5..7ca75525548abf54e00fc76a611445077760f112 100644 --- a/remoting/codec.go +++ b/remoting/codec.go @@ -1,9 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package remoting import ( "bytes" ) +// codec for exchangeClient type Codec interface { EncodeRequest(request *Request) (*bytes.Buffer, error) EncodeResponse(response *Response) (*bytes.Buffer, error) diff --git a/remoting/exchange.go b/remoting/exchange.go index eaa19f7195e205299217c5089b5cf012818d8155..45babec64bec36d93b4d3840c896b5034150b067 100644 --- a/remoting/exchange.go +++ b/remoting/exchange.go @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package remoting import ( @@ -38,12 +54,6 @@ func NewRequest(version string) *Request { } } -//func (request *Request) SetHeartbeat(isHeartbeat bool) { -// if isHeartbeat { -// -// } -//} - // Response ... type Response struct { Id int64 @@ -70,8 +80,6 @@ func (response *Response) IsHeartbeat() bool { type Options struct { // connect timeout ConnectTimeout time.Duration - // request timeout - //RequestTimeout time.Duration } //AsyncCallbackResponse async response for dubbo diff --git a/remoting/exchange_client.go b/remoting/exchange_client.go index e1778ed3a4260e7fc59450add4544ae15b9483dc..cd1e3a1017d6e32de55dbaedc0caf2fc47b0cf70 100644 --- a/remoting/exchange_client.go +++ b/remoting/exchange_client.go @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package remoting import ( @@ -24,8 +40,6 @@ type ExchangeClient struct { type Client interface { SetExchangeClient(client *ExchangeClient) SetResponseHandler(responseHandler ResponseHandler) - //invoke once for connection - //ConfigClient() Connect(url common.URL) error Close() Request(request *Request, timeout time.Duration, response *PendingResponse) error @@ -64,7 +78,6 @@ func (client *ExchangeClient) Request(invocation *protocol.Invocation, url commo rsp.response = NewResponse(request.Id, "2.0.2") rsp.Reply = (*invocation).Reply() AddPendingResponse(rsp) - //rsp.callback = invo err := client.client.Request(request, timeout, rsp) if err != nil { @@ -72,7 +85,6 @@ func (client *ExchangeClient) Request(invocation *protocol.Invocation, url commo return err } result.Rest = rsp.response.Result - //result.Attrs = rsp.response. return nil } @@ -95,7 +107,6 @@ func (client *ExchangeClient) AsyncRequest(invocation *protocol.Invocation, url return err } result.Rest = rsp.response - //result.Attrs = rsp.response. return nil } @@ -113,7 +124,6 @@ func (client *ExchangeClient) Send(invocation *protocol.Invocation, timeout time if err != nil { return err } - //result.Attrs = rsp.response. return nil } diff --git a/remoting/exchange_server.go b/remoting/exchange_server.go index dd6e76087f2508318dd42b8f116bf83a4c656b99..44f41622a225fe404dd4aa9b01348c2f3c899eee 100644 --- a/remoting/exchange_server.go +++ b/remoting/exchange_server.go @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package remoting import ( diff --git a/remoting/getty/dubbo_codec_for_test.go b/remoting/getty/dubbo_codec_for_test.go index 46ef7b939e2d2e66ff4bcfecd5c2800520cfa07e..83f0359c38109654eb68f0ab08a22699ce321c9d 100644 --- a/remoting/getty/dubbo_codec_for_test.go +++ b/remoting/getty/dubbo_codec_for_test.go @@ -1,5 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package getty +// copy from dubbo/dubbo_codec.go import ( "bufio" "bytes" diff --git a/remoting/getty/getty_client.go b/remoting/getty/getty_client.go index 9687c9cde9faf5f84178425456333d8c669192f1..a7a0c2c6ab65540da18912f16f218f187aa36509 100644 --- a/remoting/getty/getty_client.go +++ b/remoting/getty/getty_client.go @@ -108,16 +108,6 @@ type Options struct { ConnectTimeout time.Duration } -////AsyncCallbackResponse async response for dubbo -//type AsyncCallbackResponse struct { -// common.CallbackResponse -// Opts Options -// Cause error -// Start time.Time // invoke(call) start time == write start time -// ReadStart time.Time // read start time, write duration = ReadStart - Start -// Reply interface{} -//} - // Client ... type Client struct { addr string @@ -149,6 +139,7 @@ func (c *Client) SetResponseHandler(responseHandler remoting.ResponseHandler) { c.responseHandler = responseHandler } +// init client and try to connection. func (c *Client) Connect(url common.URL) error { initClient(url.Protocol) c.conf = *clientConf diff --git a/remoting/getty/listener.go b/remoting/getty/listener.go index 156a4046cb1704c95d87bcd6d8034867b68b1a6e..9d4252915d0e688ee7ed5ec3357011f88dc82b8b 100644 --- a/remoting/getty/listener.go +++ b/remoting/getty/listener.go @@ -133,25 +133,6 @@ func (h *RpcClientHandler) OnMessage(session getty.Session, pkg interface{}) { h.conn.updateSession(session) h.conn.pool.rpcClient.responseHandler.Handler(p) - - // - //pendingResponse := h.conn.pool.rpcClient.removePendingResponse(SequenceType(p.Header.ID)) - //if pendingResponse == nil { - // logger.Errorf("failed to get pending response context for response package %s", *p) - // return - //} - // - //if p.Err != nil { - // pendingResponse.err = p.Err - //} - // - //pendingResponse.response.atta = p.Body.(*Response).atta - // - //if pendingResponse.callback == nil { - // pendingResponse.done <- struct{}{} - //} else { - // pendingResponse.callback(pendingResponse.GetCallResponse()) - //} } // OnCron ... @@ -262,12 +243,6 @@ func (h *RpcServerHandler) OnMessage(session getty.Session, pkg interface{}) { return } - //twoway := true - //// not twoway - //if p.Header.Type&hessian.PackageRequest_TwoWay == 0x00 { - // twoway = false - //} - defer func() { if e := recover(); e != nil { resp.Status = hessian.Response_SERVER_ERROR @@ -334,20 +309,6 @@ func (h *RpcServerHandler) OnCron(session getty.Session) { } func reply(session getty.Session, resp *remoting.Response, tp hessian.PackageType) { - //resp := &DubboPackage{ - // Header: hessian.DubboHeader{ - // SerialID: req.Header.SerialID, - // Type: tp, - // ID: req.Header.ID, - // ResponseStatus: req.Header.ResponseStatus, - // }, - //} - // - //if resp.Event { - // resp.Result = req.Body - //} else { - // resp.Body = nil - //} if err := session.WritePkg(resp, WritePkg_Timeout); err != nil { logger.Errorf("WritePkg error: %#v, %#v", perrors.WithStack(err), resp)