HA - failover in case of service not active

This commit is contained in:
DanB
2016-05-16 16:11:08 +02:00
parent 8384f763a5
commit 9f78bad9ed
4 changed files with 37 additions and 5 deletions

View File

@@ -204,6 +204,16 @@ func (self *SMGenericV1) Call(serviceMethod string, args interface{}, reply inte
return rpcclient.ErrWrongReplyType
}
return self.ProcessCdr(argsConverted, replyConverted)
case "SMGenericV1.ActiveSessions":
argsConverted, canConvert := args.(utils.AttrSMGGetActiveSessions)
if !canConvert {
return rpcclient.ErrWrongArgsType
}
replyConverted, canConvert := reply.(*[]*sessionmanager.ActiveSession)
if !canConvert {
return rpcclient.ErrWrongReplyType
}
return self.ActiveSessions(argsConverted, replyConverted)
}
return rpcclient.ErrUnsupporteServiceMethod
}

View File

@@ -5,13 +5,21 @@
// Starts RAL
"listen": {
"rpc_json": ":12012", // RPC JSON listening address
"rpc_gob": ":12013", // RPC GOB listening address
"http": ":12080", // HTTP listening address
"rpc_json": ":12012",
"rpc_gob": ":12013",
"http": ":12080",
},
"rals": {
"enabled": true, // enable Rater service: <true|false>
"enabled": true,
},
"cdrs": {
"enabled": true,
},
"sm_generic": {
"enabled": true,
},
}

View File

@@ -26,6 +26,7 @@ import (
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/sessionmanager"
"github.com/cgrates/cgrates/utils"
"github.com/cgrates/rpcclient"
)
@@ -181,3 +182,16 @@ func TestRPCITStatusFirstFailback(t *testing.T) {
t.Errorf("Expecting: %s, received: %s", ral1ID, status[utils.InstanceID].(string))
}
}
// Make sure it executes on the first node supporting the command
func TestRPCITDirectedRPC(t *testing.T) {
if !*testIntegration {
return
}
var sessions []*sessionmanager.ActiveSession
if err := rpcPoolFirst.Call("SMGenericV1.ActiveSessions", utils.AttrSMGGetActiveSessions{}, &sessions); err != nil {
t.Error(err) // {"id":2,"result":null,"error":"rpc: can't find service SMGenericV1.ActiveSessions"}
} else if len(sessions) != 0 {
t.Errorf("Received sessions: %+v", sessions)
}
}

2
glide.lock generated
View File

@@ -20,7 +20,7 @@ imports:
- name: github.com/cgrates/osipsdagram
version: 3d6beed663452471dec3ca194137a30d379d9e8f
- name: github.com/cgrates/rpcclient
version: 9a6185f8a2093ce10f1a08242b0d757f24795800
version: e307424118247fe71aee908429555bec60c48573
- name: github.com/ChrisTrenkamp/goxpath
version: 4aad8d0161aae7d17df4755d2c1e86cd1fcaaab6
subpackages: