Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dCache
cta
Commits
37f2c781
Commit
37f2c781
authored
6 years ago
by
Eric Cano
Browse files
Options
Downloads
Patches
Plain Diff
Sepatated algoritm definitions from traits definition.
parent
627a37ba
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
objectstore/Algorithms.hpp
+5
-92
5 additions, 92 deletions
objectstore/Algorithms.hpp
objectstore/AlgorithmsTest.cpp
+1
-2
1 addition, 2 deletions
objectstore/AlgorithmsTest.cpp
objectstore/ArchiveQueueAlgorithms.hpp
+108
-0
108 additions, 0 deletions
objectstore/ArchiveQueueAlgorithms.hpp
with
114 additions
and
94 deletions
objectstore/Algorithms.hpp
+
5
−
92
View file @
37f2c781
...
@@ -29,117 +29,30 @@
...
@@ -29,117 +29,30 @@
namespace
cta
{
namespace
objectstore
{
namespace
cta
{
namespace
objectstore
{
class
EmptyClass
{};
class
ArchiveQueue
;
class
ArchiveJob
;
/**
/**
* Container traits definition. To be specialized class by class.
* Container traits definition. To be specialized class by class.
* This is mostly a model.
* This is mostly a model.
*/
*/
template
<
class
C
ontainer
>
template
<
class
C
>
class
ContainerTraits
{
class
ContainerTraits
{
public:
public:
typedef
C
Container
;
typedef
std
::
string
ContainerAddress
;
typedef
std
::
string
ContainerAddress
;
typedef
std
::
string
ElementAddress
;
typedef
std
::
string
ElementAddress
;
typedef
std
::
string
ContainerIdentifyer
;
typedef
std
::
string
ContainerIdentifyer
;
typedef
cta
::
objectstore
::
EmptyClass
Element
;
class
Element
{}
;
typedef
std
::
list
<
std
::
unique_ptr
<
Element
>>
ElementMemoryContainer
;
typedef
std
::
list
<
std
::
unique_ptr
<
Element
>>
ElementMemoryContainer
;
typedef
std
::
list
<
Element
*>
ElementPointerContainer
;
typedef
std
::
list
<
Element
*>
ElementPointerContainer
;
typedef
cta
::
objectstore
::
EmptyClass
ElementDescriptor
;
class
ElementDescriptor
{}
;
typedef
std
::
list
<
ElementDescriptor
>
ElementDescriptorContainer
;
typedef
std
::
list
<
ElementDescriptor
>
ElementDescriptorContainer
;
static
ElementAddress
getElementAddress
(
const
Element
&
e
);
static
void
getLockedAndFetched
(
Container
&
cont
,
ScopedExclusiveLock
&
contLock
,
AgentReference
&
agRef
,
const
ContainerIdentifyer
&
cId
,
static
void
getLockedAndFetched
(
Container
&
cont
,
ScopedExclusiveLock
&
contLock
,
AgentReference
&
agRef
,
const
ContainerIdentifyer
&
cId
,
log
::
LogContext
&
lc
);
log
::
LogContext
&
lc
);
static
void
addReferencesAndCommit
(
Container
&
cont
,
ElementMemoryContainer
&
elemMemCont
);
static
void
addReferencesAndCommit
(
Container
&
cont
,
ElementMemoryContainer
&
elemMemCont
);
static
ElementPointerContainer
switchElementsOwnership
(
Container
&
cont
,
ElementMemoryContainer
&
elements
,
log
::
LogContext
&
lc
);
static
ElementPointerContainer
switchElementsOwnership
(
Container
&
cont
,
ElementMemoryContainer
&
elements
,
log
::
LogContext
&
lc
);
};
};
template
<
>
class
ContainerTraits
<
ArchiveQueue
>
{
public:
typedef
ArchiveQueue
Container
;
typedef
std
::
string
ContainerAddress
;
typedef
std
::
string
ElementAddress
;
typedef
std
::
string
ContainerIdentifyer
;
struct
Element
{
std
::
unique_ptr
<
ArchiveRequest
>
archiveRequest
;
uint16_t
copyNb
;
cta
::
common
::
dataStructures
::
ArchiveFile
archiveFile
;
cta
::
common
::
dataStructures
::
MountPolicy
mountPolicy
;
};
typedef
std
::
list
<
Element
>
ElementMemoryContainer
;
struct
ElementOpFailure
{
Element
*
element
;
std
::
exception_ptr
failure
;
};
typedef
std
::
list
<
ElementOpFailure
>
ElementOpFailureContainer
;
typedef
ArchiveRequest
::
JobDump
ElementDescriptor
;
typedef
std
::
list
<
ElementDescriptor
>
ElementDescriptorContainer
;
static
ElementAddress
getElementAddress
(
const
Element
&
e
)
{
return
e
.
archiveRequest
->
getAddressIfSet
();
}
static
void
getLockedAndFetched
(
Container
&
cont
,
ScopedExclusiveLock
&
aqL
,
AgentReference
&
agRef
,
const
ContainerIdentifyer
&
tapePool
,
log
::
LogContext
&
lc
)
{
Helpers
::
getLockedAndFetchedQueue
<
ArchiveQueue
>
(
cont
,
aqL
,
agRef
,
tapePool
,
QueueType
::
LiveJobs
,
lc
);
}
static
void
addReferencesAndCommit
(
Container
&
cont
,
ElementMemoryContainer
&
elemMemCont
,
AgentReference
&
agentRef
,
log
::
LogContext
&
lc
)
{
std
::
list
<
ArchiveQueue
::
JobToAdd
>
jobsToAdd
;
for
(
auto
&
e
:
elemMemCont
)
{
ArchiveRequest
::
JobDump
jd
;
jd
.
copyNb
=
e
.
copyNb
;
jd
.
tapePool
=
cont
.
getTapePool
();
jd
.
owner
=
cont
.
getAddressIfSet
();
ArchiveRequest
&
ar
=
*
e
.
archiveRequest
;
jobsToAdd
.
push_back
({
jd
,
ar
.
getAddressIfSet
(),
e
.
archiveFile
.
archiveFileID
,
e
.
archiveFile
.
fileSize
,
e
.
mountPolicy
,
time
(
NULL
)});
}
cont
.
addJobsAndCommit
(
jobsToAdd
,
agentRef
,
lc
);
}
static
void
removeReferencesAndCommit
(
Container
&
cont
,
ElementOpFailureContainer
&
elementsOpFailures
)
{
std
::
list
<
std
::
string
>
elementsToRemove
;
for
(
auto
&
eof
:
elementsOpFailures
)
{
elementsToRemove
.
emplace_back
(
eof
.
element
->
archiveRequest
->
getAddressIfSet
());
}
cont
.
removeJobsAndCommit
(
elementsToRemove
);
}
static
ElementOpFailureContainer
switchElementsOwnership
(
ElementMemoryContainer
&
elemMemCont
,
Container
&
cont
,
const
ContainerAddress
&
previousOwnerAddress
,
log
::
LogContext
&
lc
)
{
std
::
list
<
std
::
unique_ptr
<
ArchiveRequest
::
AsyncJobOwnerUpdater
>>
updaters
;
for
(
auto
&
e
:
elemMemCont
)
{
ArchiveRequest
&
ar
=
*
e
.
archiveRequest
;
auto
copyNb
=
e
.
copyNb
;
updaters
.
emplace_back
(
ar
.
asyncUpdateJobOwner
(
copyNb
,
cont
.
getAddressIfSet
(),
previousOwnerAddress
));
}
auto
u
=
updaters
.
begin
();
auto
e
=
elemMemCont
.
begin
();
ElementOpFailureContainer
ret
;
while
(
e
!=
elemMemCont
.
end
())
{
try
{
u
->
get
()
->
wait
();
}
catch
(...)
{
ret
.
push_back
(
ElementOpFailure
());
ret
.
back
().
element
=
&
(
*
e
);
ret
.
back
().
failure
=
std
::
current_exception
();
}
u
++
;
e
++
;
}
return
ret
;
}
class
OwnershipSwitchFailure
:
public
cta
::
exception
::
Exception
{
public:
OwnershipSwitchFailure
(
const
std
::
string
&
message
)
:
cta
::
exception
::
Exception
(
message
)
{};
ElementOpFailureContainer
failedElements
;
};
};
template
<
class
C
>
template
<
class
C
>
class
ContainerAlgorithms
{
class
ContainerAlgorithms
{
public:
public:
...
...
This diff is collapsed.
Click to expand it.
objectstore/AlgorithmsTest.cpp
+
1
−
2
View file @
37f2c781
...
@@ -20,8 +20,7 @@
...
@@ -20,8 +20,7 @@
#include
"RootEntry.hpp"
#include
"RootEntry.hpp"
#include
"AgentReference.hpp"
#include
"AgentReference.hpp"
#include
"Agent.hpp"
#include
"Agent.hpp"
#include
"Algorithms.hpp"
#include
"ArchiveQueueAlgorithms.hpp"
#include
"ArchiveRequest.hpp"
#include
"common/log/DummyLogger.hpp"
#include
"common/log/DummyLogger.hpp"
#include
"tests/TestsCompileTimeSwitches.hpp"
#include
"tests/TestsCompileTimeSwitches.hpp"
#include
"catalogue/DummyCatalogue.hpp"
#include
"catalogue/DummyCatalogue.hpp"
...
...
This diff is collapsed.
Click to expand it.
objectstore/ArchiveQueueAlgorithms.hpp
0 → 100644
+
108
−
0
View file @
37f2c781
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include
"Algorithms.hpp"
#include
"ArchiveQueue.hpp"
namespace
cta
{
namespace
objectstore
{
template
<
>
class
ContainerTraits
<
ArchiveQueue
>
{
public:
typedef
ArchiveQueue
Container
;
typedef
std
::
string
ContainerAddress
;
typedef
std
::
string
ElementAddress
;
typedef
std
::
string
ContainerIdentifyer
;
struct
Element
{
std
::
unique_ptr
<
ArchiveRequest
>
archiveRequest
;
uint16_t
copyNb
;
cta
::
common
::
dataStructures
::
ArchiveFile
archiveFile
;
cta
::
common
::
dataStructures
::
MountPolicy
mountPolicy
;
};
typedef
std
::
list
<
Element
>
ElementMemoryContainer
;
struct
ElementOpFailure
{
Element
*
element
;
std
::
exception_ptr
failure
;
};
typedef
std
::
list
<
ElementOpFailure
>
ElementOpFailureContainer
;
typedef
ArchiveRequest
::
JobDump
ElementDescriptor
;
typedef
std
::
list
<
ElementDescriptor
>
ElementDescriptorContainer
;
static
ElementAddress
getElementAddress
(
const
Element
&
e
)
{
return
e
.
archiveRequest
->
getAddressIfSet
();
}
static
void
getLockedAndFetched
(
Container
&
cont
,
ScopedExclusiveLock
&
aqL
,
AgentReference
&
agRef
,
const
ContainerIdentifyer
&
tapePool
,
log
::
LogContext
&
lc
)
{
Helpers
::
getLockedAndFetchedQueue
<
ArchiveQueue
>
(
cont
,
aqL
,
agRef
,
tapePool
,
QueueType
::
LiveJobs
,
lc
);
}
static
void
addReferencesAndCommit
(
Container
&
cont
,
ElementMemoryContainer
&
elemMemCont
,
AgentReference
&
agentRef
,
log
::
LogContext
&
lc
)
{
std
::
list
<
ArchiveQueue
::
JobToAdd
>
jobsToAdd
;
for
(
auto
&
e
:
elemMemCont
)
{
ArchiveRequest
::
JobDump
jd
;
jd
.
copyNb
=
e
.
copyNb
;
jd
.
tapePool
=
cont
.
getTapePool
();
jd
.
owner
=
cont
.
getAddressIfSet
();
ArchiveRequest
&
ar
=
*
e
.
archiveRequest
;
jobsToAdd
.
push_back
({
jd
,
ar
.
getAddressIfSet
(),
e
.
archiveFile
.
archiveFileID
,
e
.
archiveFile
.
fileSize
,
e
.
mountPolicy
,
time
(
NULL
)});
}
cont
.
addJobsAndCommit
(
jobsToAdd
,
agentRef
,
lc
);
}
static
void
removeReferencesAndCommit
(
Container
&
cont
,
ElementOpFailureContainer
&
elementsOpFailures
)
{
std
::
list
<
std
::
string
>
elementsToRemove
;
for
(
auto
&
eof
:
elementsOpFailures
)
{
elementsToRemove
.
emplace_back
(
eof
.
element
->
archiveRequest
->
getAddressIfSet
());
}
cont
.
removeJobsAndCommit
(
elementsToRemove
);
}
static
ElementOpFailureContainer
switchElementsOwnership
(
ElementMemoryContainer
&
elemMemCont
,
Container
&
cont
,
const
ContainerAddress
&
previousOwnerAddress
,
log
::
LogContext
&
lc
)
{
std
::
list
<
std
::
unique_ptr
<
ArchiveRequest
::
AsyncJobOwnerUpdater
>>
updaters
;
for
(
auto
&
e
:
elemMemCont
)
{
ArchiveRequest
&
ar
=
*
e
.
archiveRequest
;
auto
copyNb
=
e
.
copyNb
;
updaters
.
emplace_back
(
ar
.
asyncUpdateJobOwner
(
copyNb
,
cont
.
getAddressIfSet
(),
previousOwnerAddress
));
}
auto
u
=
updaters
.
begin
();
auto
e
=
elemMemCont
.
begin
();
ElementOpFailureContainer
ret
;
while
(
e
!=
elemMemCont
.
end
())
{
try
{
u
->
get
()
->
wait
();
}
catch
(...)
{
ret
.
push_back
(
ElementOpFailure
());
ret
.
back
().
element
=
&
(
*
e
);
ret
.
back
().
failure
=
std
::
current_exception
();
}
u
++
;
e
++
;
}
return
ret
;
}
class
OwnershipSwitchFailure
:
public
cta
::
exception
::
Exception
{
public:
OwnershipSwitchFailure
(
const
std
::
string
&
message
)
:
cta
::
exception
::
Exception
(
message
)
{};
ElementOpFailureContainer
failedElements
;
};
};
}}
// namespace cta::objectstore
\ No newline at end of file
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