boolean persistManagedSchema(boolean createOnly){
  if (loader instanceof ZkSolrResourceLoader) {
    return persistManagedSchemaToZooKeeper(createOnly);
  }
  File managedSchemaFile=new File(loader.getConfigDir(),managedSchemaResourceName);
  OutputStreamWriter writer=null;
  try {
    File parentDir=managedSchemaFile.getParentFile();
    if (!parentDir.isDirectory()) {
      if (!parentDir.mkdirs()) {
        final String msg="Can't create managed schema directory " + parentDir.getAbsolutePath();
        log.error(msg);
        throw new SolrException(ErrorCode.SERVER_ERROR,msg);
      }
    }
    final FileOutputStream out=new FileOutputStream(managedSchemaFile);
    writer=new OutputStreamWriter(out,StandardCharsets.UTF_8);
    persist(writer);
    log.info("Upgraded to managed schema at " + managedSchemaFile.getPath());
  }
 catch (  IOException e) {
    final String msg="Error persisting managed schema " + managedSchemaFile;
    log.error(msg,e);
    throw new SolrException(ErrorCode.SERVER_ERROR,msg,e);
  }
 finally {
    IOUtils.closeQuietly(writer);
    try {
      FileUtils.sync(managedSchemaFile);
    }
 catch (    IOException e) {
      final String msg="Error syncing the managed schema file " + managedSchemaFile;
      log.error(msg,e);
    }
  }
  return true;
}

boolean persistManagedSchema ( boolean createOnly ) { if ( loader instanceof ZkSolrResourceLoader ) { return persistManagedSchemaToZooKeeper ( createOnly ) ; } File managedSchemaFile = new File ( loader . getConfigDir ( ) , managedSchemaResourceName ) ; OutputStreamWriter writer = null ; try { File parentDir = managedSchemaFile . getParentFile ( ) ; if ( ! parentDir . isDirectory ( ) ) { if ( ! parentDir . mkdirs ( ) ) { final String msg = "Can't create managed schema directory " + parentDir . getAbsolutePath ( ) ; log . error ( msg ) ; throw new SolrException ( ErrorCode . SERVER_ERROR , msg ) ; } } final FileOutputStream out = new FileOutputStream ( managedSchemaFile ) ; writer = new OutputStreamWriter ( out , StandardCharsets . UTF_8 ) ; persist ( writer ) ; log . info ( "Upgraded to managed schema at " + managedSchemaFile . getPath ( ) ) ; } catch ( IOException e ) { final String msg = "Error persisting managed schema " + managedSchemaFile ; log . error ( msg , e ) ; throw new SolrException ( ErrorCode . SERVER_ERROR , msg , e ) ; } finally { IOUtils . closeQuietly ( writer ) ; try { FileUtils . sync ( managedSchemaFile ) ; } catch ( IOException e ) { final String msg = "Error syncing the managed schema file " + managedSchemaFile ; log . error ( msg , e ) ; } } return true ; }
persist the schema to local storage or to zookeeper
