How to configure multiple hazelcast tcp-ip clusters in one yaml file? - tcp

To configure one cluster in one yml file, I could do:
hazelcast:
cluster-name: cluster1
network:
join:
multicast:
enabled: false
tcp-ip:
enabled: true
member-list:
- machineA
- machineB
However, because of the way the yaml file is structured, I find it difficult to do a yaml file with 2 clusters. If I do it the following way, it would not work:
hazelcast:
cluster-name:
- cluster1
network:
join:
multicast:
enabled: false
tcp-ip:
enabled: true
member-list:
- machineA
- machineB
- cluster2
network:
join:
multicast:
enabled: false
tcp-ip:
enabled: true
member-list:
- machineC
- machineD

You should define separate configurations per cluster. What you did is an invalid configuration. Say you have two different configurations: cluster1.yaml config and cluster2.yaml config. Then all the members of cluster1 should start with cluster1.yaml and the ones in cluster2 should use cluster2.yaml. If you need multiple clusters to be aware of each other - e.g being synchronized, consider using WAN Replication.
In that case the configurations will look like:
cluster1.yaml:
hazelcast:
cluster-name: cluster1
network:
join:
tcp-ip:
enabled: true
member-list:
- A # uses this config
- B # uses this config
cluster2.yaml:
hazelcast:
cluster-name: cluster2
network:
join:
tcp-ip:
enabled: true
member-list:
- C # uses this config
- D # uses this config

Related

Doctrine query_cache auto expire

I'm using symfony 3.4 + doctrine + redis by using the composer bundle sncRedisBundle
In my config.yml I enabled doctrine query cache:
orm:
default_entity_manager: default
entity_managers:
default:
connection: default
auto_mapping: false
metadata_cache_driver: redis
query_cache_driver: redis
result_cache_driver: redis # !!!
snc_redis:
clients:
doctrine:
type: predis
alias: doctrine_redis
dsn: "%redis_dsn_doctrine%"
logging: false
options:
connection_persistent: true
doctrine:
query_cache: #!!!!!!!!
#it caches the translation from Doctrine's DQL into SQL.
client: doctrine_redis
namespace: shop_doctrine_query
entity_manager: [default, legacy]
The keys set by doctrine for it's result_cache never expire:
How can I call automatically \Doctrine\ORM\Query::setQueryCacheLifetime or make that cache expire. (Note I don't have access to set redis eviction policies on this server).
I think that Doctrine query cache lifetime aren't configured in the doctrine package nor in the redis package, but in the framework package, where you set your pool of cache.
You should have a look on this issue where a user is asking how to configure RedisCluster with Doctrine Cache. B-Galati answers with a configuration example where it defines lifetime for doctrine result cache.
Could you try something like:
framework:
cache:
pools:
cache.doctrine.orm.default.query: ## I'm not sure of this name
adapter: cache.app
default_lifetime: 25200 # 1 week
Or
framework:
cache:
pools:
doctrine.query_cache_pool:
adapter: cache.app
default_lifetime: 25200 # 1 week
The symfony console cache:pool:list command could help you to identify your pools and the symfony console cache:pool:prune could help you to see if out of date queries are well deleted.

Spring boot 2 micormeter to statsd prefix not appending to the metrics

I've migrated spring boot 1.x to spring boot 2 with micrometer for metrics. After which could see the metrics in graphite via statsd. But, i can't see it with the prefix
After that i tried for basic prototype by following Configure micrometer-registry-statsd in spring boot 2. But, can't see metrics with prefix. It is showing from the registry name only
config:
management:
health:
defaults:
enabled: true
metrics:
enable:
example:
remote: true
export:
atlas:
enabled: false
statsd:
enabled: true
host: xx.xxx.xx.xx
port: xxxx
flavour: xxxx
step: 10s
**prefix: abc.xy**
security:
enabled: false
when i tried to print the statsdConfig properties the prefix shows as default value "statsd". After which i set the prefix property in the code too. That too didn't help.
Please share details on how to append the statsd.prefix

Symfony - Prefix all my routes with a version

Hi I would like to version my API. So I would like t prefix my roote with a version. like that?
# config/routes/annotations.yaml
controllers:
resource: ../../src/Controller/
type: annotation
prefix:
name: '{version}'
It works bit I would like to add a requirement to check the version.
Like:
requirements:
version: v1|v2
I don't find any documentation talking about that. Is there a good way to do it?
In the FOSRestBundle there is a complete chapter about versioning.
https://symfony.com/doc/master/bundles/FOSRestBundle/versioning.html
The FOSBundle has an option for versioning.
#app/config/config.yml
fos_rest:
versioning:
enabled: true
resolvers:
query: true # Query parameter: /users?version=v1
custom_header: true # X-Accept-Version header
media_type: # Accept header
enabled: true
regex: '/(v|version)=(?P<version>[0-9\.]+)/'

How do I implement a 'pillar.example' from a SaltStack Formula?

If this explanation exists somewhere, I've spent 3 months trying to find it, and failed. I come from a Puppet background, however for various reasons I really want to try replacing it with Salt.
I've gotten a basic setup and I can code my own states and see them work without any issues. The documentation on this is pretty clear. Where I'm stuck is attempting to implement a community salt formula. I can include the formula with it's basic setup and they work fine, however I cannot figure out how to override the defaults from my pillar data. This seems to be where the Salt documentation is weakest.
The documentation states that you should check the pillar.example for how to configure the formula. The pillar.example gives the configuration part clearly, however nether the documentation or the pillar.example tell you how to include this into your pillar data.
In my case I'm trying to use the snmp-formula. I've got a basic setup for my salt file structure, which you can see from my file roots:
file_roots:
base:
- /srv/salt/base
- /srv/formulas/snmp-formula
Inside base I have two pillars:
base/
top.sls
common.sls
top.sls is very simple:
base:
'*':
- common
common.sls has all common config:
include:
- snmp
- snmp.conf
- snmp.trap
- snmp.conftrap
tcpdump:
pkg.latest:
- name: tcpdump
telnet:
pkg.latest:
- name: telnet
htop:
pkg.latest:
- name: htop
snmp:
conf:
location: 'Office'
syscontact: 'Example.com Admin <admin#example.com>'
logconnects: false
# vacm com2sec's (map communities into security names)
com2sec:
- name: mynetwork
source: 192.168.0.13/31
community: public
# vacm group's (map security names to group names)
groups:
- name: MyROGroup
version: v1
secname: mynetwork
- name: MyROGroup
version: v1c
secname: mynetwork
# vacm views (map mib trees to views)
views:
- name: all
type: included
oid: '.1'
# vacm access (map groups to views with access restrictions)
access:
- name: MyROGroup
context: '""'
match: any
level: noauth
prefix: exact
read: all
write: none
notify: none
# v3 users for read-write
rwusers:
- username: 'nagios'
passphrase: 'myv3password'
view: all
In common.sls I've included the snmp-formula and then followed the pillar.example from the formula to customize the configuration. However when I run a test with this I get the following error:
Data failed to compile:
----------
Detected conflicting IDs, SLS IDs need to be globally unique.
The conflicting ID is 'snmp' and is found in SLS 'base:common' and SLS 'base:snmp'
I'm not sure how to proceed with this. It seems like I would have to actually modify the community formula directly to achieve what I want, which seems like the wrong idea. I want to be able to keep the community formula up to date with it's repository and coming from the Puppet perspective, I should be overriding a modules defaults as I need, not modifying the modules directly.
Can someone please make the missing connection for me? How do I implement the pillar.example?
The Salt formula in question is here:
https://github.com/saltstack-formulas/snmp-formula
I have finally figured this out, and it was a problem with a fundamental misunderstanding of the differences between 'file_roots' and 'pillar_roots' as well as 'pillars' vs 'states'. I don't feel that the documentation is very clear in the Getting Started guide about these so I'll explain it, but first the answer.
ANSWER:
To implement the above pillar.example, simply create a dedicated snmp.sls file in your 'base' environment in your pillar data:
/srv/pillar/snmp.sls:
snmp:
conf:
location: 'Office'
syscontact: 'Example.com Admin <admin#example.com>'
logconnects: false
# vacm com2sec's (map communities into security names)
com2sec:
- name: mynetwork
source: 192.168.0.13/31
community: public
# vacm group's (map security names to group names)
groups:
- name: MyROGroup
version: v1
secname: mynetwork
- name: MyROGroup
version: v1c
secname: mynetwork
# vacm views (map mib trees to views)
views:
- name: all
type: included
oid: '.1'
mask: 80
# vacm access (map groups to views with access restrictions)
access:
- name: MyROGroup
context: '""'
match: any
level: noauth
prefix: exact
read: all
write: none
notify: none
# v3 users for read-write
rwusers:
- username: 'nagios'
passphrase: 'myv3password'
view: all
Your pillar_root must also include a top.sls (not to be confused with the top.sls in your file_roots for your states) like this:
/srv/pillar/top.sls
base:
'*':
- snmp
IMPORTANT: This directory and this top.sls for pillar data cannot exist or be included by your file_roots! This is where I was going wrong. For a complete picture, this is the the config I now have:
/etc/salt/master: (snippet)
file_roots:
base:
- /srv/salt/base
- /srv/formulas/snmp-formula
pillar_roots:
base:
- /srv/pillar
Inside /srv/salt/base I have a top.sls which includes a common.sls
for the 'base' environment. This is where the snmp-formula and it's states are included.
/srv/salt/base/top.sls:
base/
top.sls
common.sls
/srv/salt/base/common.sls:
include:
- snmp
- snmp.conf
- snmp.trap
- snmp.conftrap
tcpdump:
pkg.latest:
- name: tcpdump
telnet:
pkg.latest:
- name: telnet
htop:
pkg.latest:
- name: htop
Now the snmp parameter in the pillar data does not conflict with ID of the snmp state from the formula included by the state data.

Two connections using Doctrine ODM with Symfony2

My problem is that I have configured two document managers like this:
doctrine_mongodb:
document_managers:
video:
connection: video
auto_mapping: true
stats:
connection: stats
auto_mapping: true
connections:
video:
server: mongodb://mongo0:27017,mongo1:27017
options:
connect: true
replicaSet: true
slaveOkay: true
stats:
server: mongodb://mongo2:27017,mongo3:27017
options:
connect: true
replicaSet: true
slaveOkay: true
default_document_manager: video
default_connection: video
default_database: my_database
I have the same name for both databases and when I load my page it seems everything's ok (loading my page I only use the 'video' document manager). However, if I use the 'stats' document manager after, symfony seems going crazy.
I have the document managers injected as services like this:
stats_service:
class: %stats_service.class%
arguments:
- #doctrine_mongodb.odm.stats_document_manager
video_service:
class: %video_service.class%
arguments:
- #doctrine_mongodb.odm.video_document_manager
I don't know why, but it seems like every time I do a query, symfony use one of the connections randomly, not the connection of the document manager injected.
Please, help!
Thanks
Ok. I have solved my problem finally. I had both replica sets with the same name and all the problems came from there.
To solved I changed the name of one of the replica sets and the attribute "replicaSet" of the configuration:
doctrine_mongodb:
document_managers:
video:
connection: video
auto_mapping: true
stats:
connection: stats
auto_mapping: true
connections:
video:
server: mongodb://mongo0:27017,mongo1:27017
options:
connect: true
replicaSet: videoReplicaset
slaveOkay: true
stats:
server: mongodb://mongo2:27017,mongo3:27017
options:
connect: true
replicaSet: statsReplicaset
slaveOkay: true
default_document_manager: video
default_connection: video
default_database: my_database
found an interesting article recommending explicit em setting here

Resources