コード例 #1
0
    @Override
    public void execute(FunctionContext context) {
      try {
        Region<K, V> local =
            PartitionRegionHelper.getLocalDataForContext((RegionFunctionContext) context);
        ParallelArgs<K, V> args = (ParallelArgs<K, V>) context.getArguments();

        File[] files =
            args.getOptions()
                .getMapper()
                .mapImportPath(
                    local.getCache().getDistributedSystem().getDistributedMember(), args.getFile());

        if (files != null) {
          for (File f : files) {
            if (f.isDirectory() || !f.exists()) {
              throw new IOException(
                  LocalizedStrings.Snapshot_INVALID_IMPORT_FILE.toLocalizedString(f));
            }
            local.getSnapshotService().load(f, args.getFormat(), args.getOptions());
          }
        }
        context.getResultSender().lastResult(Boolean.TRUE);

      } catch (Exception e) {
        context.getResultSender().sendException(e);
      }
    }