summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorneeleym <neeleym@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2013-01-31 23:44:29 +0000
committerneeleym <neeleym@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2013-01-31 23:44:29 +0000
commitd46a753948452ad94faaebe0ca15bfa08d05dbdd (patch)
tree624c32cad27afbc92eaa382ead506c0e2157f0f4
parentac24d95ef8c14c5a6f692e51d4180ed248fa80dc (diff)
downloadATCD-d46a753948452ad94faaebe0ca15bfa08d05dbdd.tar.gz
Thu Jan 31 23:31:54 UTC 2013 Marc Neeley <neeley_m@ociweb.com>
* bin/tao_other_tests.lst: * orbsvcs/tests/ImplRepo/run_test.pl: Three tests were added to test a corruption of (1) a primary listing file - persistent_listingcorrupt (2) a primary activator file - persistent_activatorcorrupt (3) a primary server file - persistent_servercorrupt Thu Jan 31 23:21:08 UTC 2013 Marc Neeley <neeley_m@ociweb.com> * orbsvcs/ImplRepo_Service/Shared_Backing_Store.h: * orbsvcs/ImplRepo_Service/Shared_Backing_Store.cpp: * orbsvcs/ImplRepo_Service/XML_Backing_Store.cpp: Added a new method to Shared_Backing_Store class called write_listing. This new method is refactoring to allow either a primary or backup listing file to be written. Modifications were also made to write to a primary and a backup file (the primary file name with a .bak ext) for the server and activator services. Reading modifications were made for listing, server, and activator files such that if the read from primary failed, then the read from the backup would be performed.
-rw-r--r--TAO/OCI_RE_ChangeLog22
-rw-r--r--TAO/bin/tao_other_tests.lst3
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Shared_Backing_Store.cpp87
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Shared_Backing_Store.h4
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/XML_Backing_Store.cpp10
-rwxr-xr-xTAO/orbsvcs/tests/ImplRepo/run_test.pl32
6 files changed, 137 insertions, 21 deletions
diff --git a/TAO/OCI_RE_ChangeLog b/TAO/OCI_RE_ChangeLog
index 868010b0db7..993a4f78ae7 100644
--- a/TAO/OCI_RE_ChangeLog
+++ b/TAO/OCI_RE_ChangeLog
@@ -1,3 +1,25 @@
+Thu Jan 31 23:31:54 UTC 2013 Marc Neeley <neeley_m@ociweb.com>
+
+ * bin/tao_other_tests.lst:
+ * orbsvcs/tests/ImplRepo/run_test.pl:
+ Three tests were added to test a corruption of
+ (1) a primary listing file - persistent_listingcorrupt
+ (2) a primary activator file - persistent_activatorcorrupt
+ (3) a primary server file - persistent_servercorrupt
+
+Thu Jan 31 23:21:08 UTC 2013 Marc Neeley <neeley_m@ociweb.com>
+
+ * orbsvcs/ImplRepo_Service/Shared_Backing_Store.h:
+ * orbsvcs/ImplRepo_Service/Shared_Backing_Store.cpp:
+ * orbsvcs/ImplRepo_Service/XML_Backing_Store.cpp:
+ Added a new method to Shared_Backing_Store class called write_listing.
+ This new method is refactoring to allow either a primary or backup
+ listing file to be written. Modifications were also made to write to
+ a primary and a backup file (the primary file name with a .bak ext)
+ for the server and activator services. Reading modifications were
+ made for listing, server, and activator files such that if the read
+ from primary failed, then the read from the backup would be performed.
+
Thu Jan 31 19:12:02 UTC 2013 Kevin Stanley <stanleyk@ociweb.com>
* bin/tao_other_tests.lst:
diff --git a/TAO/bin/tao_other_tests.lst b/TAO/bin/tao_other_tests.lst
index de37153cab0..b55276fdfb4 100644
--- a/TAO/bin/tao_other_tests.lst
+++ b/TAO/bin/tao_other_tests.lst
@@ -121,6 +121,9 @@ TAO/orbsvcs/tests/ImplRepo/run_test.pl persistent_ir_hash: !MINIMUM !CORBA_E_COM
TAO/orbsvcs/tests/ImplRepo/run_test.pl persistent_ir_shared: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !ACE_FOR_TAO !Win32
TAO/orbsvcs/tests/ImplRepo/run_test.pl failover -replica: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !ACE_FOR_TAO !Win32
TAO/orbsvcs/tests/ImplRepo/run_test.pl persistent_ft -replica: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !ACE_FOR_TAO !Win32
+TAO/orbsvcs/tests/ImplRepo/run_test.pl persistent_listingcorrupt -replica: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !ACE_FOR_TAO !Win32
+TAO/orbsvcs/tests/ImplRepo/run_test.pl persistent_activatorcorrupt -replica: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !ACE_FOR_TAO !Win32
+TAO/orbsvcs/tests/ImplRepo/run_test.pl persistent_servercorrupt -replica: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !ACE_FOR_TAO !Win32
TAO/orbsvcs/tests/ImplRepo/NameService/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !ACE_FOR_TAO
TAO/orbsvcs/tests/ImplRepo/locked/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !LynxOS !ACE_FOR_TAO
TAO/orbsvcs/tests/ImplRepo/scale/run_test.pl -servers 5 -objects 5: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !ACE_FOR_TAO !LynxOS
diff --git a/TAO/orbsvcs/ImplRepo_Service/Shared_Backing_Store.cpp b/TAO/orbsvcs/ImplRepo_Service/Shared_Backing_Store.cpp
index 4e3a9dcd55d..b4cbb0dafff 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Shared_Backing_Store.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/Shared_Backing_Store.cpp
@@ -91,10 +91,10 @@ namespace {
flags_,
0666,
unlink_in_destructor));
- if ((flags & O_RDWR) == 0)
- {
- ACE_OS::ftruncate(this->file_lock_->get_handle(), 0);
- }
+
+ // Truncating output so this will not allow reading then writing
+
+ ACE_OS::ftruncate(this->file_lock_->get_handle(), 0);
this->file_ = ACE_OS::fdopen(this->file_lock_->get_handle(), flags_str);
#endif
}
@@ -451,6 +451,7 @@ Shared_Backing_Store::persistent_update(const Server_Info_Ptr& info, bool add)
fname.c_str(), info->name.c_str()));
}
Lockable_File server_file(fname, O_WRONLY);
+ const ACE_TString bfname = fname.c_str() + ACE_TString(".bak");
FILE* fp = server_file.get_file();
if (fp == 0)
{
@@ -466,6 +467,13 @@ Shared_Backing_Store::persistent_update(const Server_Info_Ptr& info, bool add)
this->repo_values_[REPO_ID].second = entry.int_id_.repo_id_str;
persist(fp, *info, "", this->repo_values_);
+
+ // Copy the current file to a backup.
+ FILE* bfp = ACE_OS::fopen(bfname.c_str(),ACE_TEXT("w"));
+ ACE_OS::fprintf (bfp,"<?xml version=\"1.0\"?>\n");
+ persist(bfp, *info, "", this->repo_values_);
+ ACE_OS::fflush(bfp);
+ ACE_OS::fclose(bfp);
server_file.release();
const ImplementationRepository::UpdateType type = add ?
@@ -502,6 +510,7 @@ Shared_Backing_Store::persistent_update(const Activator_Info_Ptr& info,
fname.c_str(), info->name.c_str()));
}
Lockable_File activator_file(fname, O_WRONLY);
+ const ACE_TString bfname = fname.c_str() + ACE_TString(".bak");
FILE* fp = activator_file.get_file();
if (fp == 0)
{
@@ -517,6 +526,13 @@ Shared_Backing_Store::persistent_update(const Activator_Info_Ptr& info,
this->repo_values_[REPO_ID].second = entry.int_id_.repo_id_str;
persist(fp, *info, "", this->repo_values_);
+
+ // Copy the current file to a backup.
+ FILE* bfp = ACE_OS::fopen(bfname.c_str(),ACE_TEXT("w+"));
+ ACE_OS::fprintf (bfp,"<?xml version=\"1.0\"?>\n");
+ persist(bfp, *info, "", this->repo_values_);
+ ACE_OS::fflush(bfp);
+ ACE_OS::fclose(bfp);
activator_file.release();
const ImplementationRepository::UpdateType type = add ?
@@ -706,7 +722,11 @@ Shared_Backing_Store::persistent_load (bool only_changes)
{
const ACE_TString& fname = filenames[i];
Lockable_File file(fname, O_RDONLY);
- load(fname, file.get_file());
+
+ if(load(fname, file.get_file()) != 0)
+ {
+ load(fname + ".bak");
+ }
}
return 0;
@@ -732,7 +752,13 @@ Shared_Backing_Store::get_listings(Lockable_File& listing_lf,
this->opts_.debug(),
listing_lf.get_file(this->listing_file_, O_RDONLY)) != 0)
{
- listings_handler.reset();
+
+ if (load(this->listing_file_ + ".bak",
+ *listings_handler,
+ this->opts_.debug()) != 0)
+ {
+ listings_handler.reset();
+ }
}
return listings_handler;
@@ -778,7 +804,7 @@ Shared_Backing_Store::sync_load ()
return err;
}
-static void write_listing(FILE* list, const ACE_TString& fname,
+static void write_listing_item(FILE* list, const ACE_TString& fname,
const ACE_CString& name, const ACE_TCHAR* tag)
{
ACE_OS::fprintf (list, "\t<%s", tag);
@@ -786,16 +812,9 @@ static void write_listing(FILE* list, const ACE_TString& fname,
ACE_OS::fprintf (list, " name=\"%s\" />\n", name.c_str ());
}
-int
-Shared_Backing_Store::persist_listings (Lockable_File& listing_lf)
+void
+Shared_Backing_Store::write_listing(FILE* list)
{
- FILE* list = listing_lf.get_file(this->listing_file_, O_WRONLY);
- if (list == 0)
- {
- ACE_ERROR ((LM_ERROR, ACE_TEXT ("Couldn't write to file %s\n"),
- this->listing_file_.c_str()));
- return -1;
- }
ACE_OS::fprintf (list,"<?xml version=\"1.0\"?>\n");
ACE_OS::fprintf (list,"<ImRListing>\n");
@@ -806,11 +825,11 @@ Shared_Backing_Store::persist_listings (Lockable_File& listing_lf)
{
const Server_Info_Ptr& info = sientry->int_id_;
- const ServerUIMap::ENTRY& entry =
+ const Shared_Backing_Store::ServerUIMap::ENTRY& entry =
unique_id(sientry->ext_id_, this->server_uids_,
this->imr_type_, this->repo_id_);
ACE_CString listing_name = ACEXML_escape_string (info->name);
- write_listing(list, entry.int_id_.unique_filename, listing_name,
+ write_listing_item(list, entry.int_id_.unique_filename, listing_name,
Locator_XMLHandler::SERVER_INFO_TAG);
}
@@ -823,11 +842,41 @@ Shared_Backing_Store::persist_listings (Lockable_File& listing_lf)
const ActivatorUIMap::ENTRY& entry =
unique_id(aname, this->activator_uids_,
this->imr_type_, this->repo_id_);
- write_listing(list, entry.int_id_.unique_filename, aname,
+ write_listing_item(list, entry.int_id_.unique_filename, aname,
Locator_XMLHandler::ACTIVATOR_INFO_TAG);
}
ACE_OS::fprintf (list,"</ImRListing>\n");
+}
+
+int
+Shared_Backing_Store::persist_listings (Lockable_File& listing_lf)
+{
+ FILE* list = listing_lf.get_file(this->listing_file_, O_WRONLY);
+ if (list == 0)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("Couldn't write to file %s\n"),
+ this->listing_file_.c_str()));
+ return -1;
+ }
+
+ write_listing(list);
+
+ const ACE_TString bfname = this->listing_file_.c_str() + ACE_TString(".bak");
+
+ // Write backup file
+ FILE* baklist = ACE_OS::fopen(bfname.c_str(),ACE_TEXT("w"));
+ if (baklist == 0)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("Couldn't write to file %s\n"),
+ bfname.c_str()));
+ return -1;
+ }
+
+ write_listing(baklist);
+ ACE_OS::fflush(baklist);
+ ACE_OS::fclose(baklist);
+
return 0;
}
diff --git a/TAO/orbsvcs/ImplRepo_Service/Shared_Backing_Store.h b/TAO/orbsvcs/ImplRepo_Service/Shared_Backing_Store.h
index 6c6cc50bb02..fc235ba2b88 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Shared_Backing_Store.h
+++ b/TAO/orbsvcs/ImplRepo_Service/Shared_Backing_Store.h
@@ -261,6 +261,10 @@ private:
/// that will be locked when the function returns
int persist_listings(Lockable_File& listing_lf);
+ /// write content to the listings file and optionally its backup
+ /// @param File pointer to write to. Can be primary or backup.
+ void write_listing(FILE *);
+
/// connect this replica to its peer replica
/// @param this_replica a pointer to this Replica object
int connect_replicas(Replica_ptr this_replica);
diff --git a/TAO/orbsvcs/ImplRepo_Service/XML_Backing_Store.cpp b/TAO/orbsvcs/ImplRepo_Service/XML_Backing_Store.cpp
index 0262a98f1b8..1f7e6822fa8 100644
--- a/TAO/orbsvcs/ImplRepo_Service/XML_Backing_Store.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/XML_Backing_Store.cpp
@@ -238,6 +238,16 @@ XML_Backing_Store::load (const ACE_TString& filename,
ex.print ();
return -1;
}
+ catch ( const ACEXML_SAXParseException* sax_ex)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Error during load of ImR persistence xml file (%s)."),
+ filename.c_str()));
+ sax_ex->print ();
+ return -1;
+ }
+
+
return 0;
}
diff --git a/TAO/orbsvcs/tests/ImplRepo/run_test.pl b/TAO/orbsvcs/tests/ImplRepo/run_test.pl
index c4e91f8eb90..ef0edbd9f0f 100755
--- a/TAO/orbsvcs/tests/ImplRepo/run_test.pl
+++ b/TAO/orbsvcs/tests/ImplRepo/run_test.pl
@@ -1909,10 +1909,10 @@ sub persistent_ir_test
}
}
elsif ($backing_store_flag eq "--directory") {
- cleanup_replication($backing_store);
+# cleanup_replication($backing_store);
}
else {
- $imr->DeleteFile ($backing_store);
+# $imr->DeleteFile ($backing_store);
}
$imr->DeleteFile ($imriorfile);
$act->DeleteFile ($imriorfile);
@@ -2244,6 +2244,12 @@ sub failover_test
sub persistent_ft_test
{
+ my $corrupted = shift;
+
+ if (!$corrupted) {
+ $corrupted = 0;
+ }
+
if (!$replica) {
# The persistent_ft test needs the -replica flag
return 0;
@@ -2439,6 +2445,19 @@ print "Comment line arguments: -d $test_debug_level -o $repo{imr_imriorfile} " .
$replica_imr->DeleteFile ($backupiorfile);
print "killed the backup tao_imr_locator\n";
+ if($corrupted == 1){
+ my $file= "./imr_listing.xml";
+ if (open LIST_FILE, ">$file") {
+ print LIST_FILE "I'm corrupt!!!";
+ }
+ } elsif ($corrupted > 1) {
+ my $file = "./1_" .($corrupted -1). ".xml";
+ if (open LIST_FILE, ">$file") {
+ print LIST_FILE "I'm corrupt!!!";
+ }
+ }
+
+
print "\n\nstarting primary tao_imr_locator again\n";
$repo{IMR}->Arguments ("-d $test_debug_level -o $repo{imr_imriorfile} " .
"$imr_refstyle $repo{imr_endpoint_flag} $repo{imr_backing_store_flag}");
@@ -2859,6 +2878,15 @@ for ($i = 0; $i <= $#ARGV; $i++) {
elsif ($ARGV[$i] eq "persistent_ft") {
$ret = persistent_ft_test ();
}
+ elsif ($ARGV[$i] eq "persistent_listingcorrupt") {
+ $ret = persistent_ft_test (1);
+ }
+ elsif ($ARGV[$i] eq "persistent_activatorcorrupt") {
+ $ret = persistent_ft_test (2);
+ }
+ elsif ($ARGV[$i] eq "persistent_servercorrupt") {
+ $ret = persistent_ft_test (3);
+ }
elsif ($ARGV[$i] eq "failover") {
$ret = failover_test ();
}