Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
HdbTdbArchivingServers
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software Control System
Tango controls archiving
HdbTdbArchivingServers
Commits
26030eda
Commit
26030eda
authored
Mar 10, 2011
by
Gwenaelle ABEILLE
Browse files
Options
Downloads
Patches
Plain Diff
check export before writing in file to avoid empty files
parent
ed45e4e3
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/TdbArchiver/Collector/Tools/FileTools.java
+43
-36
43 additions, 36 deletions
src/main/java/TdbArchiver/Collector/Tools/FileTools.java
with
43 additions
and
36 deletions
src/main/java/TdbArchiver/Collector/Tools/FileTools.java
+
43
−
36
View file @
26030eda
...
...
@@ -246,6 +246,7 @@ public class FileTools {
private
int
attributePerFile
;
private
Date
creationFileDate
;
private
final
long
exportPeriod
;
public
FileTools
(
final
String
attributeName
,
final
String
tableName
,
final
int
dataFormat
,
final
int
writable
,
final
long
windowsDuration
,
final
ILogger
logger
,
final
DbProxy
dbProxy
,
final
String
workingDsPath
,
final
String
workingDbPath
)
throws
IOException
,
ArchivingException
{
...
...
@@ -327,7 +328,7 @@ public class FileTools {
String
writeValue
=
scalarEvent
.
valueToString
(
1
);
final
long
timeStampValue
=
scalarEvent
.
getTimeStamp
();
if
(
isValidLine
(
timeStampValue
))
{
doExport
();
if
(
dbProxy
.
getDataBase
().
getDbConn
().
getDbType
()
==
ConfigConst
.
TDB_ORACLE
)
{
if
(
readValue
==
null
||
GlobalConst
.
ARCHIVER_NULL_VALUE
.
equalsIgnoreCase
(
readValue
.
trim
()))
{
readValue
=
GlobalConst
.
ORACLE_NULL_VALUE
;
...
...
@@ -376,36 +377,40 @@ public class FileTools {
switch
(
scalarEvent
.
getWritable
())
{
case
AttrWriteType
.
_READ
:
write
(
new
StringBuffer
().
append
(
toDbTimeStringMySQL
(
scalarEvent
.
getTimeStamp
())).
append
(
ConfigConst
.
FIELDS_LIMIT
).
append
(
readValue
).
append
(
ConfigConst
.
LINES_LIMIT
).
toString
());
write
(
new
StringBuffer
().
append
(
toDbTimeStringMySQL
(
scalarEvent
.
getTimeStamp
()))
.
append
(
ConfigConst
.
FIELDS_LIMIT
).
append
(
readValue
).
append
(
ConfigConst
.
LINES_LIMIT
)
.
toString
());
break
;
case
AttrWriteType
.
_READ_WITH_WRITE
:
write
(
new
StringBuffer
().
append
(
toDbTimeStringMySQL
(
scalarEvent
.
getTimeStamp
()))
.
append
(
ConfigConst
.
FIELDS_LIMIT
).
append
(
readValue
).
append
(
ConfigConst
.
FIELDS_LIMIT
)
.
append
(
writeValue
).
append
(
ConfigConst
.
LINES_LIMIT
).
toString
());
write
(
new
StringBuffer
().
append
(
toDbTimeStringMySQL
(
scalarEvent
.
getTimeStamp
()))
.
append
(
ConfigConst
.
FIELDS_LIMIT
).
append
(
readValue
).
append
(
ConfigConst
.
FIELDS_LIMIT
)
.
append
(
writeValue
).
append
(
ConfigConst
.
LINES_LIMIT
).
toString
());
break
;
case
AttrWriteType
.
_WRITE
:
write
(
new
StringBuffer
().
append
(
toDbTimeStringMySQL
(
scalarEvent
.
getTimeStamp
())).
append
(
ConfigConst
.
FIELDS_LIMIT
).
append
(
writeValue
).
append
(
ConfigConst
.
LINES_LIMIT
).
toString
());
write
(
new
StringBuffer
().
append
(
toDbTimeStringMySQL
(
scalarEvent
.
getTimeStamp
()))
.
append
(
ConfigConst
.
FIELDS_LIMIT
).
append
(
writeValue
).
append
(
ConfigConst
.
LINES_LIMIT
)
.
toString
());
break
;
case
AttrWriteType
.
_READ_WRITE
:
write
(
new
StringBuffer
().
append
(
toDbTimeStringMySQL
(
scalarEvent
.
getTimeStamp
()))
.
append
(
ConfigConst
.
FIELDS_LIMIT
).
append
(
readValue
).
append
(
ConfigConst
.
FIELDS_LIMIT
)
.
append
(
writeValue
).
append
(
ConfigConst
.
LINES_LIMIT
).
toString
());
write
(
new
StringBuffer
().
append
(
toDbTimeStringMySQL
(
scalarEvent
.
getTimeStamp
()))
.
append
(
ConfigConst
.
FIELDS_LIMIT
).
append
(
readValue
).
append
(
ConfigConst
.
FIELDS_LIMIT
)
.
append
(
writeValue
).
append
(
ConfigConst
.
LINES_LIMIT
).
toString
());
break
;
}
}
doExport
();
}
else
{
logger
.
trace
(
ILogger
.
LEVEL_INFO
,
"This timestamps has already been inserted : "
+
new
Timestamp
(
timeStampValue
)
+
" in the file "
+
fileName
);
logger
.
trace
(
ILogger
.
LEVEL_INFO
,
"This timestamps has already been inserted : "
+
new
Timestamp
(
timeStampValue
)
+
" in the file "
+
fileName
+
"for "
+
scalarEvent
.
getAttribute_complete_name
());
}
}
catch
(
final
IOException
e
)
{
e
.
printStackTrace
();
logger
.
trace
(
ILogger
.
LEVEL_ERROR
,
"ERROR !! "
+
"\r\n"
+
"\t Origin : \t "
+
"FileTools.processEventScalar"
+
"\r\n"
+
"\t Reason : \t "
+
e
.
getClass
().
getName
()
+
"\r\n"
+
"\t Description : \t "
+
e
.
getMessage
()
+
"\r\n"
+
"\t Additional information : \t "
+
"File :\t "
+
fileName
+
"\r\n"
);
logger
.
trace
(
ILogger
.
LEVEL_ERROR
,
"IOException for "
+
scalarEvent
.
getAttribute_complete_name
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
logger
.
trace
(
ILogger
.
LEVEL_ERROR
,
"Unknow Exception for "
+
scalarEvent
.
getAttribute_complete_name
());
}
}
...
...
@@ -423,7 +428,7 @@ public class FileTools {
}
else
if
(
attributePerFile
>
0
)
{
writtenAttributes
++;
if
(
writtenAttributes
>=
attributePerFile
||
elapseTime
>=
exportPeriod
)
{
logger
.
trace
(
ILogger
.
LEVEL_DEBUG
,
"export
because of
writtenAttributes "
+
writtenAttributes
logger
.
trace
(
ILogger
.
LEVEL_DEBUG
,
"export
due to
writtenAttributes "
+
writtenAttributes
+
" - elapseTime "
+
elapseTime
);
switchFile
();
writtenAttributes
=
0
;
...
...
@@ -449,7 +454,7 @@ public class FileTools {
final
long
timeStampValue
=
spectrumEvent_ro
.
getTimeStamp
();
if
(
isValidLine
(
timeStampValue
))
{
doExport
();
if
(
spectrumEvent_ro
.
getData_type
()
==
TangoConst
.
Tango_DEV_STRING
)
{
final
String
[]
value
=
(
String
[])
spectrumEvent_ro
.
getValue
();
String
[]
transformedValue
=
null
;
...
...
@@ -468,10 +473,10 @@ public class FileTools {
if
(
GlobalConst
.
ARCHIVER_NULL_VALUE
.
equals
(
value
))
{
value
=
GlobalConst
.
ORACLE_NULL_VALUE
;
}
write
(
new
StringBuffer
().
append
(
"\""
)
.
append
(
DateUtil
.
milliToString
(
spectrumEvent_ro
.
getTimeStamp
(),
DateUtil
.
FR_DATE_PATTERN
))
.
append
(
"\""
).
append
(
","
).
append
(
"\""
).
append
(
Double
.
toString
(
spectrumEvent_ro
.
getDim_x
()))
.
append
(
"\""
).
append
(
","
).
append
(
"\""
).
append
(
value
).
append
(
"\""
).
toString
());
write
(
new
StringBuffer
().
append
(
"\""
)
.
append
(
DateUtil
.
milliToString
(
spectrumEvent_ro
.
getTimeStamp
(),
DateUtil
.
FR_DATE_PATTERN
))
.
append
(
"\""
).
append
(
","
).
append
(
"\""
).
append
(
Double
.
toString
(
spectrumEvent_ro
.
getDim_x
()))
.
append
(
"\""
).
append
(
","
).
append
(
"\""
).
append
(
value
).
append
(
"\""
).
toString
());
write
(
ConfigConst
.
NEW_LINE
);
}
else
if
(
dbProxy
.
getDataBase
().
getDbConn
().
getDbType
()
==
ConfigConst
.
TDB_MYSQL
)
{
...
...
@@ -488,7 +493,7 @@ public class FileTools {
buff
.
append
(
ConfigConst
.
LINES_LIMIT
);
write
(
buff
.
toString
());
}
doExport
();
}
else
{
logger
.
trace
(
ILogger
.
LEVEL_INFO
,
"This timestamps has already been inserted : "
+
new
Timestamp
(
timeStampValue
)
+
" in the file "
+
fileName
);
...
...
@@ -591,6 +596,7 @@ public class FileTools {
public
synchronized
void
processEventImage
(
final
ImageEvent_RO
imageEvent_ro
)
throws
ArchivingException
{
try
{
doExport
();
if
(
imageEvent_ro
.
getData_type
()
==
TangoConst
.
Tango_DEV_STRING
)
{
final
String
[]
value
=
(
String
[])
imageEvent_ro
.
getValue
();
String
[]
transformedValue
=
null
;
...
...
@@ -604,22 +610,23 @@ public class FileTools {
}
if
(
dbProxy
.
getDataBase
().
getDbConn
().
getDbType
()
==
ConfigConst
.
TDB_ORACLE
)
{
write
(
new
StringBuffer
().
append
(
"\""
).
append
(
DateUtil
.
milliToString
(
imageEvent_ro
.
getTimeStamp
(),
DateUtil
.
FR_DATE_PATTERN
)).
append
(
"\""
)
.
append
(
","
).
append
(
"\""
).
append
(
Double
.
toString
(
imageEvent_ro
.
getDim_x
())).
append
(
"\""
)
.
append
(
","
).
append
(
"\""
).
append
(
Double
.
toString
(
imageEvent_ro
.
getDim_y
())).
append
(
"\""
)
.
append
(
","
).
append
(
"\""
).
append
(
imageEvent_ro
.
getValue_AsString
()).
append
(
"\""
).
toString
());
write
(
new
StringBuffer
().
append
(
"\""
)
.
append
(
DateUtil
.
milliToString
(
imageEvent_ro
.
getTimeStamp
(),
DateUtil
.
FR_DATE_PATTERN
))
.
append
(
"\""
).
append
(
","
).
append
(
"\""
).
append
(
Double
.
toString
(
imageEvent_ro
.
getDim_x
()))
.
append
(
"\""
).
append
(
","
).
append
(
"\""
).
append
(
Double
.
toString
(
imageEvent_ro
.
getDim_y
()))
.
append
(
"\""
).
append
(
","
).
append
(
"\""
).
append
(
imageEvent_ro
.
getValue_AsString
()).
append
(
"\""
)
.
toString
());
write
(
ConfigConst
.
NEW_LINE
);
}
else
if
(
dbProxy
.
getDataBase
().
getDbConn
().
getDbType
()
==
ConfigConst
.
TDB_MYSQL
)
{
final
long
timeStampValue
=
imageEvent_ro
.
getTimeStamp
();
if
(
isValidLine
(
timeStampValue
))
{
write
(
new
StringBuffer
().
append
(
"\""
)
.
append
(
DateUtil
.
milliToString
(
imageEvent_ro
.
getTimeStamp
(),
DateUtil
.
FR_DATE_PATTERN
))
write
(
new
StringBuffer
().
append
(
"\""
)
.
append
(
DateUtil
.
milliToString
(
imageEvent_ro
.
getTimeStamp
(),
DateUtil
.
FR_DATE_PATTERN
))
.
append
(
"\""
).
append
(
","
).
append
(
"\""
).
append
(
Double
.
toString
(
imageEvent_ro
.
getDim_x
()))
.
append
(
"\""
).
append
(
","
).
append
(
"\""
).
append
(
Double
.
toString
(
imageEvent_ro
.
getDim_y
()))
.
append
(
"\""
).
append
(
","
).
append
(
"\""
).
append
(
imageEvent_ro
.
getValue_AsString
())
.
append
(
"\""
).
toString
());
.
append
(
"\""
).
append
(
","
).
append
(
"\""
).
append
(
imageEvent_ro
.
getValue_AsString
())
.
append
(
"\""
).
toString
());
write
(
ConfigConst
.
NEW_LINE
);
}
else
{
logger
.
trace
(
ILogger
.
LEVEL_INFO
,
"This timestamps has already been inserted : "
...
...
@@ -627,7 +634,7 @@ public class FileTools {
}
}
doExport
();
}
catch
(
final
IOException
e
)
{
Util
.
out2
.
println
(
"ERROR !! "
+
"\r\n"
+
"\t Origin : \t "
+
"FileTools.processEventImage"
+
"\r\n"
+
"\t Reason : \t "
+
e
.
getClass
().
getName
()
+
"\r\n"
+
"\t Description : \t "
+
e
.
getMessage
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment