新しい投稿

検索

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
質問
· 2024年10月10日

How to Switch Namespaces and Access %SYS Namespace in an OpenAPI-Generated Classmethod?

Hello everyone,

I'm working with a class generated by OpenAPI in InterSystems IRIS, specifically impl.cls. In one of the classmethods of this class, I need to switch to the %SYS namespace to access system-level functionalities and then switch back to the original namespace.

I tried using the following commands:

new $namespace
set $namespace = “%SYS”

However, these give an error when executed. Is there a proper way to change namespaces programmatically within a classmethod and gain access to the %SYS namespace? Any best practices or example code snippets would be greatly appreciated!

Thank you!

5 Comments
ディスカッション (5)3
続けるにはログインするか新規登録を行ってください
お知らせ
· 2024年10月10日

[Video] Creating Virtual Models with Adaptive Analytics

Hi, Community!

Want to use your data to make better business decisions? Creating virtual models can help! See how:

Creating Virtual Models with InterSystems IRIS® Adaptive Analytics

In this video, you will learn:

  • How to quickly and easily create virtual data models
  • How the built-in AI of Adaptive Analytics improves your query speed

Continue learning with InterSystems IRIS Adaptive Analytics Essentials (online course, 2h).

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
質問
· 2024年10月10日

Simple Way To Compare Streams

Is there a simple way to compare Stream data between two objects?

We have used $ZCRC to create a checksum and that seems to be work.

We have also read each line of the streams and compared them and that seems to work too.

We just think there has to be a simpler way than looping through all the lines of the stream.

Any suggestions would be appreciated.

7 Comments
ディスカッション (7)3
続けるにはログインするか新規登録を行ってください
記事
· 2024年10月10日 2m read

Script de Freeze em servidores espelhados

Olá comunidade!

Eu trago aqui uma dica para poupar algumas horas do seu dia. A documentação InterSystems especifica muito bem como criar um script de freeze para as instâncias, mas não traz exemplos em instâncias espelhadas, onde queremos deixar o script automático, mas só rodar efetivamente na instância primária.

Primeiro, vamos criar uma classe abstrata no namespace %SYS com métodos que verificam se a instância é primária e, caso positivo, executam o freeze.

Class User.custom.FreezeThaw.Script [ Abstract ]
{

ClassMethod FreezeIfPrimary() As %Status
{
    Set tSC = $$$OK
    
    Try
    {
        If ##class(%SYSTEM.Mirror).IsPrimary()
        {
            Set tSC = ##class(Backup.General).ExternalFreeze()
        }
    }
    Catch Exception
    {
        Set tSC = Exception.AsStatus()
    }
    
    Quit tSC
}
}

Agora, escrevemos em um arquivo o script para congelar se for primária. Vou deixar esse arquivo no caminho /opt/script/, onde será criado um log:

#!/bin/bash
# variables used for returning the status
success=0
error=1
warning=2
status=$success
log_path="/opt/script/freezescript.log"
echo "`date` Logs:\n" >> $log_path
instance="IRISDB02"

# IRIS
iris session $instance -U%SYS "##Class(User.custom.FreezeThaw.Script).FreezeIfPrimary()"
status=$?
if [ $status -eq 0 ]; then
	echo "$instance IS FROZEN"
        printf  "$instance IS FROZEN\n" >> $log_path
else
        echo "$instance FREEZE FAILED"
        printf  "$instance FREEZE FAILED\n" >> $log_path
       	status=$error
        iris session $instance -U%SYS "##Class(User.custom.FreezeThaw.Script).ThawIfPrimary()" >> $log_path
fi

Finalmente, podemos escrever o método de descongelamento

ClassMethod ThawIfPrimary() As %Status
{
    Set tSC = $$$OK
    
    Try
    {
        If ##class(%SYSTEM.Mirror).IsPrimary()
        {
            Set tSC = ##class(Backup.General).ExternalThaw()
        }
    }
    Catch Exception
    {
        Set tSC = Exception.AsStatus()
    }
    
    Quit tSC
}

E é claro, no mesmo caminho, criamos um script para o descongelamento:

#!/bin/bash
# variables used for returning the status
success=0
error=1
warning=2
status=$success
log_path="/opt/script/freezescript.log"
instance="IRISDB02"

# IRIS
iris session $instance -U%SYS "##Class(User.custom.FreezeThaw.Script).ThawIfPrimary()" >> $log_path
status=$?
if [ $status -eq 0 ]; then
        echo "SYSTEM IS UNFROZEN"
        printf  "`date` SYSTEM IS UNFROZEN\n" >> $log_path
else
        echo "SYSTEM UNFREEZE FAILED"
        printf  "SYSTEM UNFREEZE FAILED\n" >> $log_path
        status=$error
fi

É isto! Estão prontos seus scripts para executar snapshot sem problemas.

Obrigada por ler e sinta-se à vontade para compartilhar ideias e dúvidas nos comentários.

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください