|
|
#1 (permalink) |
|
Guest
Posts: n/a
|
I have a Java server controller that read/write to Database table
Java server will start read / write to a new DB table every week/monday e.g. table-1-2-2012 table-1-9-2012 table-1-16-2012 table-1-23-2012 ... etc I think of 2 ways to do the DB table rotation 1) check the server timestamp, if today's date is week of 1-23-2012, then read/write to table-1-23- 2012 2) have a unix corn job run every monday to generate a text file on Java server with DB table named on that date - on each Java request, check the text file's table name - then read/write to that DB table any other solution to DB table rotation? the first way check timestamp have a drawback when server's time is not set to correct time, since there are many Java server running for load balance, it's not a good idea. the second way is a better solution, but request additional setup - cron job |
|
|
|
#2 (permalink) |
|
Guest
Posts: n/a
|
On 1/30/2012 9:08 PM, Jim Lee wrote:
> I have a Java server controller that read/write to Database table > > Java server will start read / write to a new DB table every > week/monday > e.g. > table-1-2-2012 > table-1-9-2012 > table-1-16-2012 > table-1-23-2012 ... etc > > I think of 2 ways to do the DB table rotation > > 1) check the server timestamp, if today's date is week of 1-23-2012, > then read/write to table-1-23- > > 2012 > > 2) have a unix corn job run every monday to generate a text file on > Java server with DB table named on > > that date - on each Java request, check the text file's table name - > then read/write to that DB table > > any other solution to DB table rotation? > > the first way check timestamp have a drawback when server's time is > not set to correct time, since > > there are many Java server running for load balance, it's not a good > idea. > > the second way is a better solution, but request additional setup - > cron job I can not see any any problems with construction the table name every time you need it. That string formatting will be insignificant compared to the actual database operation. And it will be far more expensive to read from a file. So definitely #1. Arne |
|
|
|
#3 (permalink) |
|
Guest
Posts: n/a
|
On 1/30/2012 9:12 PM, Arne Vajhøj wrote:
> On 1/30/2012 9:08 PM, Jim Lee wrote: >> I have a Java server controller that read/write to Database table >> >> Java server will start read / write to a new DB table every >> week/monday >> e.g. >> table-1-2-2012 >> table-1-9-2012 >> table-1-16-2012 >> table-1-23-2012 ... etc >> >> I think of 2 ways to do the DB table rotation >> >> 1) check the server timestamp, if today's date is week of 1-23-2012, >> then read/write to table-1-23- >> >> 2012 >> >> 2) have a unix corn job run every monday to generate a text file on >> Java server with DB table named on >> >> that date - on each Java request, check the text file's table name - >> then read/write to that DB table >> >> any other solution to DB table rotation? >> >> the first way check timestamp have a drawback when server's time is >> not set to correct time, since >> >> there are many Java server running for load balance, it's not a good >> idea. >> >> the second way is a better solution, but request additional setup - >> cron job > > I can not see any any problems with construction the table > name every time you need it. > > That string formatting will be insignificant compared to > the actual database operation. > > And it will be far more expensive to read from a file. > > So definitely #1. But also consider if you really want to switch table like that. Why not just use the same table all the time with a column for the period? For most cases that would be the best solution. Exceptions do exist. Arne |
|
|
|
#4 (permalink) |
|
Guest
Posts: n/a
|
On Mon, 30 Jan 2012 21:12:14 -0500, Arne Vajh?j <arne@vajhoej.dk>
wrote: >On 1/30/2012 9:08 PM, Jim Lee wrote: >> I have a Java server controller that read/write to Database table >> >> Java server will start read / write to a new DB table every >> week/monday >> e.g. >> table-1-2-2012 >> table-1-9-2012 >> table-1-16-2012 >> table-1-23-2012 ... etc >> >> I think of 2 ways to do the DB table rotation >> >> 1) check the server timestamp, if today's date is week of 1-23-2012, >> then read/write to table-1-23- >> >> 2012 >> >> 2) have a unix corn job run every monday to generate a text file on >> Java server with DB table named on >> >> that date - on each Java request, check the text file's table name - >> then read/write to that DB table >> >> any other solution to DB table rotation? >> >> the first way check timestamp have a drawback when server's time is >> not set to correct time, since >> >> there are many Java server running for load balance, it's not a good >> idea. >> >> the second way is a better solution, but request additional setup - >> cron job > >I can not see any any problems with construction the table >name every time you need it. to construct the table name, i need to use the server timestamp, what if the server time is incorrect? then everything is messed up? On linux, is the server time always in sync with internet time server? or it's depended on the motherboard BIOS time? > >That string formatting will be insignificant compared to >the actual database operation. > >And it will be far more expensive to read from a file. > >So definitely #1. > >Arne |
|
|
|
#5 (permalink) |
|
Guest
Posts: n/a
|
On 1/30/2012 9:17 PM, Jim Lee wrote:
> On Mon, 30 Jan 2012 21:12:14 -0500, Arne Vajh?j<arne@vajhoej.dk> > wrote: > >> On 1/30/2012 9:08 PM, Jim Lee wrote: >>> I have a Java server controller that read/write to Database table >>> >>> Java server will start read / write to a new DB table every >>> week/monday >>> e.g. >>> table-1-2-2012 >>> table-1-9-2012 >>> table-1-16-2012 >>> table-1-23-2012 ... etc >>> >>> I think of 2 ways to do the DB table rotation >>> >>> 1) check the server timestamp, if today's date is week of 1-23-2012, >>> then read/write to table-1-23- >>> >>> 2012 >>> >>> 2) have a unix corn job run every monday to generate a text file on >>> Java server with DB table named on >>> >>> that date - on each Java request, check the text file's table name - >>> then read/write to that DB table >>> >>> any other solution to DB table rotation? >>> >>> the first way check timestamp have a drawback when server's time is >>> not set to correct time, since >>> >>> there are many Java server running for load balance, it's not a good >>> idea. >>> >>> the second way is a better solution, but request additional setup - >>> cron job >> >> I can not see any any problems with construction the table >> name every time you need it. > > to construct the table name, i need to use the server timestamp, what > if the server time is incorrect? then everything is messed up? On > linux, is the server time always in sync with internet time server? or > it's depended on the motherboard BIOS time? If you can not get the time correctly to construct a tablename then you can not get the time correctly to write to the file. You can setup NTP to synch time. But does it matter if one server is 2 seconds off? Arne |
|
|
|
#6 (permalink) |
|
Guest
Posts: n/a
|
On Mon, 30 Jan 2012 18:08:04 -0800, Jim Lee wrote:
> I have a Java server controller that read/write to Database table > > Java server will start read / write to a new DB table every week/monday > e.g. > table-1-2-2012 table-1-9-2012 table-1-16-2012 table-1-23-2012 ... etc > What problem are you using table rotation to solve? What would prevent you from using a single table containing datestamped rows which are archived and/or deleted the rows after "cycle length" days? -- martin@ | Martin Gregorie gregorie. | Es***, UK org | |
|
|
|
#7 (permalink) |
|
Guest
Posts: n/a
|
On Mon, 30 Jan 2012 21:14:21 -0500, Arne Vajh?j <arne@vajhoej.dk>
wrote: >On 1/30/2012 9:12 PM, Arne Vajh?j wrote: >> On 1/30/2012 9:08 PM, Jim Lee wrote: >>> I have a Java server controller that read/write to Database table >>> >>> Java server will start read / write to a new DB table every >>> week/monday >>> e.g. >>> table-1-2-2012 >>> table-1-9-2012 >>> table-1-16-2012 >>> table-1-23-2012 ... etc >>> >>> I think of 2 ways to do the DB table rotation >>> >>> 1) check the server timestamp, if today's date is week of 1-23-2012, >>> then read/write to table-1-23- >>> >>> 2012 >>> >>> 2) have a unix corn job run every monday to generate a text file on >>> Java server with DB table named on >>> >>> that date - on each Java request, check the text file's table name - >>> then read/write to that DB table >>> >>> any other solution to DB table rotation? >>> >>> the first way check timestamp have a drawback when server's time is >>> not set to correct time, since >>> >>> there are many Java server running for load balance, it's not a good >>> idea. >>> >>> the second way is a better solution, but request additional setup - >>> cron job >> >> I can not see any any problems with construction the table >> name every time you need it. >> >> That string formatting will be insignificant compared to >> the actual database operation. >> >> And it will be far more expensive to read from a file. >> >> So definitely #1. > >But also consider if you really want to switch table like >that. > >Why not just use the same table all the time with a column >for the period? > >For most cases that would be the best solution. Exceptions >do exist. > >Arne I must use a new table |
|
|
|
#8 (permalink) |
|
Guest
Posts: n/a
|
1-2 sec off is not matter
On Mon, 30 Jan 2012 21:20:14 -0500, Arne Vajh?j <arne@vajhoej.dk> wrote: >On 1/30/2012 9:17 PM, Jim Lee wrote: >> On Mon, 30 Jan 2012 21:12:14 -0500, Arne Vajh?j<arne@vajhoej.dk> >> wrote: >> >>> On 1/30/2012 9:08 PM, Jim Lee wrote: >>>> I have a Java server controller that read/write to Database table >>>> >>>> Java server will start read / write to a new DB table every >>>> week/monday >>>> e.g. >>>> table-1-2-2012 >>>> table-1-9-2012 >>>> table-1-16-2012 >>>> table-1-23-2012 ... etc >>>> >>>> I think of 2 ways to do the DB table rotation >>>> >>>> 1) check the server timestamp, if today's date is week of 1-23-2012, >>>> then read/write to table-1-23- >>>> >>>> 2012 >>>> >>>> 2) have a unix corn job run every monday to generate a text file on >>>> Java server with DB table named on >>>> >>>> that date - on each Java request, check the text file's table name - >>>> then read/write to that DB table >>>> >>>> any other solution to DB table rotation? >>>> >>>> the first way check timestamp have a drawback when server's time is >>>> not set to correct time, since >>>> >>>> there are many Java server running for load balance, it's not a good >>>> idea. >>>> >>>> the second way is a better solution, but request additional setup - >>>> cron job >>> >>> I can not see any any problems with construction the table >>> name every time you need it. >> >> to construct the table name, i need to use the server timestamp, what >> if the server time is incorrect? then everything is messed up? On >> linux, is the server time always in sync with internet time server? or >> it's depended on the motherboard BIOS time? > >If you can not get the time correctly to construct a tablename >then you can not get the time correctly to write to the file. > >You can setup NTP to synch time. > >But does it matter if one server is 2 seconds off? > >Arne > |
|
|
|
#9 (permalink) |
|
Guest
Posts: n/a
|
On Tue, 31 Jan 2012 02:21:11 +0000 (UTC), Martin Gregorie
<martin@address-in-sig.invalid> wrote: >On Mon, 30 Jan 2012 18:08:04 -0800, Jim Lee wrote: > >> I have a Java server controller that read/write to Database table >> >> Java server will start read / write to a new DB table every week/monday >> e.g. >> table-1-2-2012 table-1-9-2012 table-1-16-2012 table-1-23-2012 ... etc >> >What problem are you using table rotation to solve? > >What would prevent you from using a single table containing datestamped >rows which are archived and/or deleted the rows after "cycle length" days? my main problem is how to make sure "how to get the correct table name to read/write to" depending what day in the week start a new DB table is a must since it's going through some other REST backend layer |
|
|
|
#10 (permalink) |
|
Guest
Posts: n/a
|
On 1/30/2012 9:23 PM, Jim Lee wrote:
> On Mon, 30 Jan 2012 21:20:14 -0500, Arne Vajh?j<arne@vajhoej.dk> > wrote: >> On 1/30/2012 9:17 PM, Jim Lee wrote: >>> On Mon, 30 Jan 2012 21:12:14 -0500, Arne Vajh?j<arne@vajhoej.dk> >>> wrote: >>> >>>> On 1/30/2012 9:08 PM, Jim Lee wrote: >>>>> I have a Java server controller that read/write to Database table >>>>> >>>>> Java server will start read / write to a new DB table every >>>>> week/monday >>>>> e.g. >>>>> table-1-2-2012 >>>>> table-1-9-2012 >>>>> table-1-16-2012 >>>>> table-1-23-2012 ... etc >>>>> >>>>> I think of 2 ways to do the DB table rotation >>>>> >>>>> 1) check the server timestamp, if today's date is week of 1-23-2012, >>>>> then read/write to table-1-23- >>>>> >>>>> 2012 >>>>> >>>>> 2) have a unix corn job run every monday to generate a text file on >>>>> Java server with DB table named on >>>>> >>>>> that date - on each Java request, check the text file's table name - >>>>> then read/write to that DB table >>>>> >>>>> any other solution to DB table rotation? >>>>> >>>>> the first way check timestamp have a drawback when server's time is >>>>> not set to correct time, since >>>>> >>>>> there are many Java server running for load balance, it's not a good >>>>> idea. >>>>> >>>>> the second way is a better solution, but request additional setup - >>>>> cron job >>>> >>>> I can not see any any problems with construction the table >>>> name every time you need it. >>> >>> to construct the table name, i need to use the server timestamp, what >>> if the server time is incorrect? then everything is messed up? On >>> linux, is the server time always in sync with internet time server? or >>> it's depended on the motherboard BIOS time? >> >> If you can not get the time correctly to construct a tablename >> then you can not get the time correctly to write to the file. >> >> You can setup NTP to synch time. >> >> But does it matter if one server is 2 seconds off? > > 1-2 sec off is not matter Synching time today is not difficult. Arne |
|