Collector Replica Management in ArcServer

1222
1
01-08-2019 12:22 AM
Status: Open
MPC_KineticGIS_Department
Occasional Contributor

Having now been running collector within our organisation for the last 4 years I have come across several issues with managing the ever increasing replicas generated from substantial use. One of our databases has over 400 replicas due to the volume of users and number of maps downloaded.

There are several scenarios in which orphaned replicas can be created in the offline workflows:

  • Device Lost, Damaged
  • Device Hard Reset
  • App Uninstalled
  • Network dropout during initial download

Recently I had a scenario in which a database had blown out substantially in size, after detailed investigation there were several replicas which had been orphaned for some time and were storing a large amount of changes. Currently the tools are problematic to identify which replicas we can safely remove and which need to be kept.

doing this manually is very time consuming and has dangers due to the interface in which you can remove a replica is not able to have a filter applied, and crashes when you sort the table more than once.

You can access using python the last sent and last received dates for a replica but you can't access when a replica was created? Neither can you un-register a replica using python, although I suspect this is a good thing as this has large disaster potential. We do need a better way to mange this potential mine field of performance and storage liability better.

Personally I would like a means to use the properties you can get from arcpy.da.ListReplicas to include the created date and be able to use the Replica Class properties in other tools or as a means to filter the replicas in a more stable dialog window. Potentially an ability to "TAG" a replica with the results of a python script would be incredibly helpful.

Add extra Column and sort and filter buttons

This BUG with the Replica Manager button has been consistent since 10.3 when I first found it. Still waiting for a fix other than don;t click on the column title more than once.

Give it a try happens every time

1 Comment
MPC_KineticGIS_Department

So with complete frustration with the processes available I have managed to scrape together info from multiple sources to build this simple script that outputs the main info you need about your replicas.

Runs infinitely faster than the embedded arcpy.da.ListReplicas module and gives you better more useful information.

Just need to filter the list based on your criteria and feed into the API backend of ArcServer to remove the ones you need.

import pyodbc
import datetime

print datetime.datetime.now()
conn_str = (
    r'Driver={SQL Server};'
    r'Server=SERVER\INSTANCE;'
    r'Database=DATABASENAME;'
    r'Trusted_Connection=yes;'
    )
cnxn = pyodbc.connect(conn_str)

cursor = cnxn.cursor()
query = """WITH 
  cteReplicaLog(ReplicaID, MaxLogDate)
  AS 
  (
    SELECT ReplicaID, MAX(LogDate)
    FROM   sde.GDB_REPLICALOG
    GROUP  BY ReplicaID
  )
SELECT 
    ITEMS.UUID,
    ITEMS.Definition .value( '(/GPReplica/ID)[1]', 'nvarchar(max)') AS "ID" ,
    ITEMS.Definition .value( '(/GPReplica/Name)[1]', 'nvarchar(max)') AS "Replica Name" ,
    ITEMS.Definition .value( '(/GPReplica/ReplicaVersion)[1]', 'nvarchar(max)') AS "Replica Version" ,
    ITEMS.Definition .value( '(/GPReplica/CreationDate)[1]', 'smalldatetime') AS "Creation Date",
       ISNULL(CAST(replicalog.MaxLogDate AS smalldatetime), NULL) AS 'Sync Time'
FROM          
              sde.GDB_ITEMS AS items
              INNER JOIN sde.GDB_ITEMTYPES AS itemtypes
              ON items.Type = itemtypes.UUID
              LEFT JOIN cteReplicaLog AS replicalog
              ON items.ObjectID = replicalog.ReplicaID
WHERE
              itemtypes.Name = 'Replica'
ORDER  BY 'Replica Name', 'Sync Time' ;
"""
cursor.execute(query)
replicas_data = []
while 1:
    row = cursor.fetchone()
    if not row:
        print replicas_data
        break
    replicas_data.append(row)
cnxn.close()
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍