mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
integrated cassandra in the development docker
This commit is contained in:
@@ -10,8 +10,14 @@ RUN gpg --keyserver pool.sks-keyservers.net --recv-key D76EDC7725E010CF && gpg -
|
||||
# add freeswitch apt repo
|
||||
RUN echo 'deb http://files.freeswitch.org/repo/deb/debian/ jessie main' > /etc/apt/sources.list.d/freeswitch.list
|
||||
|
||||
# add cassandra gpg keys
|
||||
RUN gpg --keyserver pgp.mit.edu --recv-keys F758CE318D77295D; gpg --export --armor F758CE318D77295D | apt-key add -;gpg --keyserver pgp.mit.edu --recv-keys 2B5C1B00;gpg --export --armor 2B5C1B00 | apt-key add -;gpg --keyserver pgp.mit.edu --recv-keys 0353B12C;gpg --export --armor 0353B12C | apt-key add -
|
||||
|
||||
# add cassandra repo
|
||||
RUN echo 'deb http://www.apache.org/dist/cassandra/debian 21x main' > /etc/apt/sources.list.d/cassandra.list
|
||||
|
||||
# install dependencies
|
||||
RUN apt-get -y update && apt-get -y install git bzr mercurial redis-server mysql-server python-pycurl python-mysqldb postgresql postgresql-client sudo wget freeswitch-meta-vanilla vim zsh
|
||||
RUN apt-get -y update && apt-get -y install git bzr mercurial redis-server mysql-server python-pycurl python-mysqldb postgresql postgresql-client cassandra sudo wget freeswitch-meta-vanilla vim zsh
|
||||
|
||||
# add cgrates user
|
||||
RUN useradd -c CGRateS -d /var/run/cgrates -s /bin/false -r cgrates
|
||||
@@ -20,7 +26,7 @@ RUN useradd -c CGRateS -d /var/run/cgrates -s /bin/false -r cgrates
|
||||
RUN wget -qO- https://storage.googleapis.com/golang/go1.5.1.linux-amd64.tar.gz | tar xzf - -C /root/
|
||||
|
||||
#install oh-my-zsh
|
||||
RUN sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"; exit 0
|
||||
RUN TERM=xterm sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"; exit 0
|
||||
|
||||
# cleanup
|
||||
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
# edit servers config files
|
||||
sed -i 's/127.0.0.1/0.0.0.0/g' /etc/redis/redis.conf /etc/mysql/my.cnf
|
||||
echo 'host all all 0.0.0.0/32 md5'>>/etc/postgresql/9.4/main/pg_hba.conf
|
||||
sed -i 's/ulimit/#ulimit/g' /etc/init.d/cassandra
|
||||
|
||||
/etc/init.d/mysql start
|
||||
/etc/init.d/postgresql start
|
||||
/etc/init.d/redis-server start
|
||||
/etc/init.d/cassandra start
|
||||
|
||||
# create a link to data dir
|
||||
ln -s /root/code/src/github.com/cgrates/cgrates/data /usr/share/cgrates
|
||||
|
||||
@@ -17,3 +17,8 @@ import:
|
||||
- package: github.com/cgrates/osipsdagram
|
||||
- package: github.com/cgrates/kamevapi
|
||||
- package: github.com/cgrates/fsock
|
||||
- package: github.com/gocql/gocql
|
||||
- package: github.com/golang/snappy
|
||||
- package: gopkg.in/inf.v0
|
||||
|
||||
|
||||
|
||||
56
engine/storage_cassandra.go
Normal file
56
engine/storage_cassandra.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package engine
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
"github.com/gocql/gocql"
|
||||
)
|
||||
|
||||
type CassandraStorage struct {
|
||||
keyspace string
|
||||
db *gocql.Session
|
||||
ms Marshaler
|
||||
}
|
||||
|
||||
func NewCassandraStorage(addresses []string, keyspace, mrshlerStr string) (*CassandraStorage, error) {
|
||||
cluster := gocql.NewCluster(addresses...)
|
||||
cluster.Keyspace = keyspace
|
||||
session, err := cluster.CreateSession()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var mrshler Marshaler
|
||||
if mrshlerStr == utils.MSGPACK {
|
||||
mrshler = NewCodecMsgpackMarshaler()
|
||||
} else if mrshlerStr == utils.JSON {
|
||||
mrshler = new(JSONMarshaler)
|
||||
} else {
|
||||
return nil, fmt.Errorf("Unsupported marshaler: %v", mrshlerStr)
|
||||
}
|
||||
return &CassandraStorage{db: session, keyspace: keyspace, ms: mrshler}, nil
|
||||
}
|
||||
|
||||
func (cs *CassandraStorage) Close() {
|
||||
cs.db.Close()
|
||||
}
|
||||
|
||||
func (cs *CassandraStorage) Flush(ignore string) (err error) {
|
||||
return cs.db.Query(fmt.Sprintf("delete * from %s", cs.keyspace)).Exec()
|
||||
}
|
||||
|
||||
func (cs *CassandraStorage) SetRatedCdr(*StoredCdr) error { return nil }
|
||||
func (cs *CassandraStorage) LogCallCost(cgrid, source, runid string, cc *CallCost) error { return nil }
|
||||
func (cs *CassandraStorage) GetCallCostLog(cgrid, source, runid string) (*CallCost, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (cs *CassandraStorage) GetStoredCdrs(*utils.CdrsFilter) ([]*StoredCdr, int64, error) {
|
||||
return nil, 0, nil
|
||||
}
|
||||
func (cs *CassandraStorage) RemStoredCdrs([]string) error { return nil }
|
||||
func (cs *CassandraStorage) LogError(uuid, source, runid, errstr string) error { return nil }
|
||||
func (cs *CassandraStorage) LogActionTrigger(ubId, source string, at *ActionTrigger, as Actions) error {
|
||||
return nil
|
||||
}
|
||||
func (cs *CassandraStorage) LogActionPlan(source string, at *ActionPlan, as Actions) error { return nil }
|
||||
@@ -34,3 +34,9 @@ import:
|
||||
ref: a376b1f937ba959857929fa3e111c0f3243278c0
|
||||
- package: github.com/cgrates/fsock
|
||||
ref: 7ec136e2798fbfe44f713f5ee5828ce643dec4c2
|
||||
- package: github.com/gocql/gocql
|
||||
ref: 5c0a2c93853c0e6d6806853c000afd694b5851f7
|
||||
- package: github.com/golang/snappy
|
||||
ref: 723cc1e459b8eea2dea4583200fd60757d40097a
|
||||
- package: gopkg.in/inf.v0
|
||||
ref: 3887ee99ecf07df5b447e9b00d9c0b2adaa9f3e4
|
||||
|
||||
Reference in New Issue
Block a user