30 July, 2011

mysql master<->master replication

server 1 :

/etc/my.cnf
[mysqld]
# номер сервера, у всех реплицируемых серверов они должны быть уникальными
server-id = 1
log-bin = mysql-bin
# конфигурация серера, как мастера
log-bin = /var/lib/mysql/mysql-bin

# конфигурация сервера, как слейва
relay-log = /var/lib/mysql/mysql-relay-bin
relay-log-index = /var/lib/mysql/mysql-relay-bin.index
replicate-do-db = test_db

server 2 :
/etc/my.cnf
[mysqld]
# номер сервера, у всех реплицируемых серверов они должны быть уникальными
server-id = 1
log-bin = mysql-bin
# конфигурация серера, как мастера
log-bin = /var/lib/mysql/mysql-bin

# конфигурация сервера, как слейва
relay-log = /var/lib/mysql/mysql-relay-bin
relay-log-index = /var/lib/mysql/mysql-relay-bin.index
replicate-do-db = test_db
==============================================================

mysql @server_1 :

mysql> CHANGE MASTER TO MASTER_HOST='server_2', MASTER_PORT=N, MASTER_USER='NAME', MASTER_PASSWORD='PASSWORD';

GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'NAME'@'%' IDENTIFIED BY 'PASSWORD';


mysql @server_2 :

mysql> CHANGE MASTER TO MASTER_HOST='server_1',
MASTER_PORT=N,
MASTER_USER='NAME',
MASTER_PASSWORD='PASSWORD';

GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'NAME'@'%' IDENTIFIED BY 'PASSWORD';

==================================================================

in case of :

ERROR 1201 (HY000): Could not initialize master info structure; more error messages can be found in the MySQL error log) ... :

1. read mysql err file.
2. mysql>STOP SLAVE;
3. mysql>RESET SLAVE;
4. mysql>START SLAVE;

==================================================================

thats all.

02 July, 2011

spikko + asterisk + freepbx = friends

Outgoing Settings :

host=sip.spikko.com
username=*username*
secret=*password*
type=peer
disallow=all
allow=g729&gsm&ulaw&alaw
nat=no
port=5090
fromuser=*username*
insecure=port,invite
call-limit=1
directmedia=no


Incoming Settings :

USER Context: *username*
secret=*password*
type=user
context=from-trunk
username=*username*
canreinvite=no
insecure=port,invite
disallow=all
allow=g729&gsm&ulaw&alaw
call-limit=2
directmedia=no


Registration :

Register String: *username*:*password*@sip.spikko.com:5090/*username*

23 May, 2008

adding facet management to eclipse project

1. open .project file
2. add to natures tag next line :
org.eclipse.wst.common.project.facet.core.nature

16 May, 2008

.msi files extracting

First, access an elevated command prompt, to do this:

1. Click the Start button.

2. Click All Programs.

3. Go into Accessories.

4. Right-click on Command Prompt.

5. Select Run as administrator.

6. When the UAC Prompt appears, click Continue.


Once you have your elevated command prompt, input the following:



msiexec /a filepath to MSI file /qb TARGETDIR=filepath to target folder

using the desired locations to fill the above mentioned filepaths.
(Example: msiexec /a c:\testfile.msi /qb TARGETDIR=c:\temp\test)

31 December, 2007

Spring->Qiartz->Concurrent job

Using the MethodInvokingJobDetailFactoryBean, you don't need to create one-line jobs that just invoke a method, and you only need to create the actual business object and wire up the detail object.
By default, Quartz Jobs are stateless, resulting in the possibility of jobs interfering with each other. If you specify two triggers for the same JobDetail, it might be possible that before the first job has finished, the second one will start. If JobDetail classes implement the Stateful interface, this won't happen. The second job will not start before the first one has finished. To make jobs resulting from the MethodInvokingJobDetailFactoryBean non-concurrent, set the concurrent flag to false.



<bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">

<property name="targetObject" ref="exampleBusinessObject">

<property name="targetMethod" value="doIt">

<property name="concurrent" value="false">

</bean>


оч хороший пример : http://firstpartners.net/kb/index.php/Cron_Timer_functionality_using_Spring_and_Quartz

30 December, 2007

Hibernate find by "Criteria" of member collection

the problem is to get mapped entity by few search criterias where one or more from them related to member types/collection members of this top level element

the aswer is to use "Criteria" and also add criteria to member of top level entity by calling criteria.createCriteria(member object/collection name) :


Criteria cr = getSession().createCriteria(Some_DT.class).setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);

cr.add(Restrictions.in(member_name, some_collection));
cr.add(Restrictions.ge(member_name, some_value));
cr.add(Restrictions.le(member_name, some_value));
cr.add(Restrictions.in(member_name, some_collection));

cr.createCriteria(member object/collection name).add(Restrictions.like(child member->member name, "%"+some value+"%"));


неплохой пост описывающий ту же ситуацию : http://lucker.intervelopers.com/java/cc_join/

26 December, 2007

ResourceBundle via JDBC

will be updated shortly