-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes fixes
- Loading branch information
Showing
5 changed files
with
174 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
log_level: debug | ||
|
||
host: '::1' | ||
router_port: '6432' | ||
admin_console_port: '7432' | ||
grpc_api_port: '7010' | ||
|
||
world_shard_fallback: true | ||
router_mode: PROXY | ||
|
||
use_coordinator_init: true | ||
|
||
with_coordinator: true | ||
|
||
frontend_tls: | ||
key_file: /etc/odyssey/ssl/server.key | ||
cert_file: /etc/odyssey/ssl/server.crt | ||
sslmode: disable | ||
|
||
frontend_rules: | ||
- usr: user1 | ||
db: db1 | ||
pool_mode: TRANSACTION | ||
pool_prepared_statement: true | ||
auth_rule: | ||
auth_method: ok | ||
password: strong | ||
- pool_mode: TRANSACTION | ||
pool_default: true | ||
pool_prepared_statement: false | ||
auth_rule: | ||
auth_method: ok | ||
|
||
backend_rules: | ||
- usr: user1 | ||
db: db1 | ||
pool_discard: false | ||
pool_rollback: true | ||
- pool_default: true | ||
pool_discard: false | ||
pool_rollback: true | ||
|
||
shards: | ||
sh1: | ||
tls: | ||
key_file: /etc/odyssey/ssl/server.key | ||
sslmode: disable | ||
cert_file: /etc/odyssey/ssl/server.crt | ||
db: db1 | ||
usr: user1 | ||
pwd: 12345678 | ||
type: DATA | ||
hosts: | ||
- 'localhost:5550' | ||
sh2: | ||
tls: | ||
key_file: /etc/odyssey/ssl/server.key | ||
sslmode: disable | ||
cert_file: /etc/odyssey/ssl/server.crt | ||
db: db1 | ||
usr: user1 | ||
pwd: 12345678 | ||
type: DATA | ||
hosts: | ||
- 'localhost:5551' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,65 @@ | ||
package instance | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/pg-sharding/spqr/pkg/models/distributions" | ||
"github.com/pg-sharding/spqr/pkg/models/kr" | ||
"github.com/pg-sharding/spqr/pkg/spqrlog" | ||
"github.com/pg-sharding/spqr/qdb" | ||
) | ||
|
||
type EtcdMetadataBootstraper struct { | ||
RouterMetadataBootstraper | ||
QdbAddr string | ||
} | ||
|
||
// InitializeMetadata implements RouterMetadataBootstraper. | ||
func (e *EtcdMetadataBootstraper) InitializeMetadata(ctx context.Context, r RouterInstance) error { | ||
etcdConn, err := qdb.NewEtcdQDB(e.QdbAddr) | ||
if err != nil { | ||
return err | ||
} | ||
defer etcdConn.Client().Close() | ||
|
||
/* Initialize distributions */ | ||
ds, err := etcdConn.ListDistributions(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for _, d := range ds { | ||
if err := r.Console().Mgr().CreateDistribution(ctx, distributions.DistributionFromDB(d)); err != nil { | ||
spqrlog.Zero.Error().Err(err).Msg("failed to initialize instance") | ||
return err | ||
} | ||
|
||
/* initialize key ranges within distribution */ | ||
krs, err := etcdConn.ListKeyRanges(ctx, d.ID) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for _, ckr := range krs { | ||
if err := r.Console().Mgr().CreateKeyRange(ctx, kr.KeyRangeFromDB(ckr)); err != nil { | ||
spqrlog.Zero.Error().Err(err).Msg("failed to initialize instance") | ||
return err | ||
} | ||
} | ||
} | ||
|
||
c, err := etcdConn.GetCoordinator(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
if err := r.Console().Mgr().UpdateCoordinator(ctx, c); err != nil { | ||
return err | ||
} | ||
|
||
r.Initialize() | ||
|
||
return nil | ||
} | ||
|
||
func NewEtcdMetadataBootstraper(QdbAddr string) RouterMetadataBootstraper { | ||
return &EtcdMetadataBootstraper{QdbAddr: QdbAddr} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters